I have an XML webservice whose single method SendXMLRequest(string xml) receives XML data. The webservice is working fine if I consume it with a POST action from a web form or if I integrate it into the C# code base in other projects.
I am now trying to call SendXMLRequest with jQuery.ajax() (v1.91) but I've found that if the xml data that is passed in contains nested XML tags then the return status code is 400 'Bad Request'. Removing the nesting makes the call work. In production the XML data passed in will always include nested tags so I would greatly appreciated any tips on how to fix this.
Here is the js code I'm using for the ajax call.
var mySOAP = '<?xml version="1.0" encoding="utf-8"?> \
<soap12:Envelope xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY" xmlns:soap12="http://ift.tt/18hkEkn"> \
<soap12:Body> \
<SendXMLRequest xmlns="http://tempuri.org/"> \
<xml>
<requestor>
<id>97efbb6d-6aaa-4729-a47f-00658b5ce0c7</id> \
<username>mattma</username> \
</requestor> \
</xml> \
</SendXMLRequest> \
</soap12:Body></soap12:Envelope>';
$.ajax({
type: "POST",
url: "http://localhost/webservicerequest.asmx",
contentType: "application/soap+xml; charset=utf-8",
dataType: "xml",
cache: false,
processData: false,
data: mySOAP,
success: SuccessOccur,
error: ErrorOccur
});
};
thanks in advance for your help. Matt
No comments:
Post a Comment