The question comes up again and again, but nowhere in the web seems to be the correct answer (although I describe it in my German
JavaScript book since quite some time). The topic is using JavaScript to call Web Services from within Mozilla type browsers. Whereas this is quite well-documented and works more or less seamlessly with PHP Web Services, .NET Web Services are problematic. Calling the Web Service works, as does parsing the return data. However, on the server end, only empty parameters arrive.
The trick is to manually set the type for the parameters you are sending to the server. So after creating a parameter:
var p = new SOAPParameter(value, name);
Then, you load the correct type; in this case, I am using
string, but you could use other schema types like
integer, as well:
var enc = new SOAPEncoding();
enc = senc.getAssociatedEncoding(
"http://schemas.xmlsoap.org/soap/encoding/",
false);
var coll = enc.schemaCollection;
var type = coll.getType(
"string",
"http://www.w3.org/2001/XMLSchema");
Finally, you link the type to the parameter:
p.schemaType = type;
And that's it! The rest is business as usual: Instantiate the
SOAPCall class, set the required properties, call
encode(), call
asyncInvoke(), implement a callback function, and you are done.
By the way: When using the
Atlas framework, you do not need this browser-specific code any more; calling .NET Web Services works in a browser-agnostic fashion here.