WCF Service:
public class Service1 : IService1 {
$.ajax({public class Service1 : IService1 {
public string GetData(int value) { return string.Format("You entered: {0}", value); } }
JavaScript:function Retrieve(id) {jQuery.support.cors = true; var soapData = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' + '<s:Body><GetData xmlns="http://tempuri.org/"><value>200</value></GetData></s:Body></s:Envelope>';
type: "POST", contentType: "text/xml; charset=utf-8", dataType: "xml", url: "http://localhost:58282/Service1.svc", data: soapData, beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://tempuri.org/IService1/GetData"); }, success: RetrieveCallbackSuccess, error: RetrieveCallbackError });
}
function RetrieveCallbackSuccess(response) {
alert("Yey! :) --> " + response.text);
}function RetrieveCallbackError(err) { alert("Onoz! :( --> " + err.statusText); }
The line "jQuery.support.cors = true" is important for cross domain requests.
Cheers,
Markus
This comment has been removed by a blog administrator.
ReplyDelete