Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to send xml parameter to WCF?
    primarykey
    data
    text
    <p>How to send xml parameter to call <code>WCF</code> method? My client side code is in <code>AJAX,JSON</code> using jQuery.I want to pass xml value as parameter.How to pass xml value? My xml value is</p> <pre><code>&lt;value&gt;&lt;Root&gt;mydata&lt;/Root&gt;&lt;/value&gt; </code></pre> <p>My client side code--</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" &gt; jQuery.support.cors = true; var bhRequest = "&lt;s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;" + "&lt;s:Body&gt;" + "&lt;GetSMC xmlns=\"http://tempuri.org/\"&gt;" + "&lt;value&gt;&lt;Root&gt;MyValue&lt;/Root&gt;&lt;/value&gt;" + "&lt;/GetSMC&gt;" + "&lt;/s:Body&gt;" + "&lt;/s:Envelope&gt;"; $(document).ready(function () { $("#btnWCFBasicHttp").click(function () { alert("hi"); $.ajax({ type: "POST", url: "http://localhost:8130/MyService.svc/bh/", data: bhRequest, timeout: 10000, contentType: "text/xml", dataType: "xml", beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://tempuri.org/IMyService/GetSMC"); }, success: function (data) { alert("success"); $(data).find("GetSMCResponse").each(function () { document.getElementById('Label2').innerHTML = $(this).find("GetSMCResult").text(); }); }, error: function (xhr, status, error) { alert(error); } }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;input id="btnWCFREST" type="button" value="Call WCF using JQuery" /&gt; &lt;label ID="Label1" runat="server" Text="Label"&gt;&lt;/label&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </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