I have created one WCF restful service.
public string Demo(String xmlString)
{
//do stuff
}
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, Method = "Post", UriTemplate = "Demo",
BodyStyle = WebMessageBodyStyle.Wrapped)]
string Demo(String xmlString);
I am sending through
$(document).ready(function () {
$("#btn").click(function () {
var bhRequest = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Body>" +
"<GetSMC xmlns=\"http://tempuri.org/\">" +
"<value><Root>MyValue</Root></value>" +
"</GetSMC>" +
"</s:Body>" +
"</s:Envelope>";
var bhReq="<![CDATA[" + bhRequest + "]]>";
alert(bhReq);
$.ajax({
url: 'http://localhost:15536/Plugins/MyPlugin/RemoteService/WebService.svc/Demo',
type: 'POST',
data: '{"xmlString":"'+ bhReq +'"}',
contentType: "text/xml",
dataType: "xml",
success: function (data) {
alert(Successfull);
},
error: function (data) {
alert('Error Occurred');
}
});
});
});
Call is not going to service and gives error of
NetworkError: 405 Method Not Allowed
XML Parsing Error: not well-formed Location: moz-nullprincipal:{70ef8883-a52b-4e70-a1ca-bdf5c611c23c} Line Number 1, Column 1:
{"xmlString":"MyValue</Root></value></GetSMC></s:Body></s:Envelope>]]>"}
I have also passed some text that is pass in my service but xml string is not passing.
I have also done using set my service request and response format to json and pass data from my script using datatype json it's also not working.
Please give any solution how i can pass xml as a string value from javascript to my wcf rest service.