c# - How can I call a SOAP Web Service without Adding Web Reference -


I need to develop a .NET 4.5 client for SOAP based web service. The problem is that the company that has these SOAP Based services, they do not provide WSDL. Although they provide the Request Response Schema (XSD files) since there are no WSDLs, I am unable to add a web context and self-induce the client proxy code.

Is there any .NET 4.5 library from which I can use to make these SOAP base service calls? It also needs to support SOAP 1.1 and SOAP attachements.

If for some reason you do not want to create WSDL file, the example given below is manually a SOAP Can be used to create an HTTP request:

  var url = Settings.Default.URL; // 'Web service URL' var verb = settings. default.SoAPAction; // SOAP Method / Action Name var soapEnvelopeXml = CreateSoapEnvelope (); Var soapRequest = CreateSoapRequest (url, action); InsertSoapEnvelopeIntoSoapRequest (soapEnvelopeXml, SOAP); (Using the word stringWriter = new stringwriter ()) ({var xmlWriter = XmlWriter.Create (stringWriter)) {soapEnvelopeXml.WriteTo (xmlWriter); XmlWriter.Flush (); }} // start async calls on web request Var asyncResult = soapRequest.BeginGetResponse (empty, incomplete); // Suspend this thread until the call is completed. You want // to work useful here to update your UI here. Var success = asyncResult.AsyncWaitHandle.WaitOne (timespace.formscandes (5)); If (! Success) return tap; // Receive feedback from entire web request (using var webResponse = soapRequest.EndGetResponse (asyncResult)) {string soapResult; Var responseSwami = WebRanspence Gateresonsstream (); If (responses == zero) {return tap; } {SoapResult = reader.ReadToEnd (); using Var Reader = new streamrider (responses); } Return soap result; } Private Static HttpWebRequest CreateSoapRequest (string url, string action) {var webRequest = (HttpWebRequest) WebRequest.Create (url); WebRequest.Headers.Add ("SOAPAction", verb); WebRequest.ContentType = "text / xml; charset = \" utf-8 \ ""; WebRequest.Accept = "text / xml"; WebRequest.method = "post"; Return webRequest; } Private Static XmlDocument CreateSoapEnvelope () {var soapEnvelope = new XmlDocument (); SoapEnvelope.LoadXml (Settings.Default.SOAPEnvelope); // SOAPEnvelope to send SOAP envelope; } Private Static Zero InsertSoapEnvelopeIntoSoapRequest (XmlDocument soapEnvelopeXml, HttpWebRequest webRequest) {usage (stream stream = webRequest.GetRequestStream ()) {soapEnvelopeXml.Save (stream); }}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -