Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect to WCF Web Service using Jquery and Soap-XML
    primarykey
    data
    text
    <p>I have a simple WCF web service I tried to connect with jquery and SOAP-XML ( dataType: "xml" ) .but when i send my request i get "BAD REQUEST Error 400" from my server. here is my SOAP-XML:</p> <pre><code>var soapMessage = '&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"&gt; \ &lt;soap:Header&gt; \ &lt;Action soap:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\"&gt;http://tempuri.org/IService/HelloWorld&lt;/Action&gt; \ &lt;/soap:Header&gt; \ &lt;soap:Body&gt; \ &lt;HelloWorld xmlns="http://tempuri.org/"&gt; \ &lt;/HelloWorld&gt; \ &lt;/soap:Body&gt; \ &lt;/soap:Envelope&gt;'; </code></pre> <p>and this is my $.Ajax :</p> <pre><code>var productServiceUrl = 'http://localhost:3523/Service.svc/HelloWorld'; $.ajax({ url: productServiceUrl, type: "POST", dataType: "xml", data: soapMessage, complete: endSaveProduct, contentType: "text/xml; charset=\"utf-8\"", async: true, error: function (xhr, textStatus, errorThrown) { alert(errorThrown); } }); </code></pre> <p>and here is Detail of Request and Responce (I trace this in Google Chrome):</p> <p>Request Hedear </p> <blockquote> <pre><code>POST /Service.svc/HelloWorld HTTP/1.1 Host: localhost:3523 Connection: keep-alive Content-Length: 550 Origin: http://localhost:3523 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.15 Safari/535.2 Content-Type: text/xml; charset="UTF-8" Accept: application/xml, text/xml, */*; q=0.01 Referer: http://localhost:3523/WcfService.htm Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 </code></pre> </blockquote> <p>and my Response Header </p> <pre><code> HTTP/1.1 400 Bad Request Server: ASP.NET Development Server/10.0.0.0 Date: Wed, 04 Jan 2012 14:56:06 GMT X-AspNet-Version: 4.0.30319 Cache-Control: private Content-Length: 0 Connection: Close </code></pre> <p>Request payload: </p> <pre><code>&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"&gt; &lt;soap:Header&gt;&lt;Action soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/IService/HelloWorld&lt;/Action&gt; &lt;/soap:Header&gt;&lt;soap:Body&gt;&lt;HelloWorld xmlns="http://tempuri.org/"&gt;&lt;/HelloWorld&gt;&lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>and this if my WCF web service:</p> <pre><code>[OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)] String HelloWorld(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload