Encountered a situation where sending a SOAP request with an array of strings through Ajax results in the request being successfully passed to the web service. However, upon deserialization, the array is rendered empty.
The ASP.Net WebService features the given contract:
[WebService(Namespace = "http://someCompany.com/WebServices/TCWS/Agent")]
public class AgentService : WebService
Highlighted by the following API:
[WebMethod(Description = "my action description", MessageName = "MyAction")]
public Result MyAction(string[] items)
An AJAX call (using Javascript) is executed as follows:
AgentService.prototype.DoSoapAjax = function (methodName, data, successHandler, errorHandler, state) {
// Need to use local variable so ajax request will be able to process the guid variable
var currGuid = window.AgentGUID;
var response = $.ajax({
type: "POST",
contentType: "text/xml; charset=utf-8",
methodName: methodName,
url: this.AgentServiceUrl,
data: data,
...
A demonstration of how DoSoapAjax is called:
AgentService.prototype.MyAction= function (items, successHandler, errorHandler, state) {
var items = "<items arrayType='string[]'><item xsi:type='string'>first text</items><item xsi:type='string'>second text</items></items>";
...
Exhibiting the SOAP request:
<?xml version='1.0' encoding='utf-8'?>
<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/soap/envelope/'>
<soap:Body>
<MyAction xmlns='http://someCompany.com/WebServices/TCWS/Agent'>
<items xsi:type='string'>first text</items>
<items xsi:type='string'>second text</items>
</MyAction>
</soap:Body>
</soap:Envelope>
Upon debugging the web service, it becomes apparent that while reaching the MyAction method, the 'items' array appears empty instead of containing 2 strings. Is there an issue present within my SOAP request?