Calling an ASP.NET Web Service from a Mozilla Browser


var schematype = schemacoll.getType(   "integer",   "http://www.w3.org/2001/XMLSchema" ); 

There is one potential issue with the preceding code: The data types for the parameters sent to the Web Service are not provided. Unfortunately, some Web Service implementations require this information to work. Most notably, some .NET Web Services do not work without this information.

It is hard to say who is to blame for that, Microsoft or Mozilla, but at least there is a way to make these two systems cooperate. To do so, you have to change the way the parameters are created. After instantiating the SOAPCall class, you have to load the correct encoding for each parameter. In the example, the data type used is integer, so that's what we are using. The parameters array is now created in the following fashion:

Calling a Web Service with Distinctive Data Types from Mozilla (webservice-mozilla-php.html; excerpt)

var l = new SOAPParameter(parseInt(   f.elements["lower"].value), "lower"); var u = new SOAPParameter(parseInt(   f.elements["upper"].value), "upper"); var soapenc = new SOAPEncoding(); assenc = soapenc.getAssociatedEncoding(   "http://schemas.xmlsoap.org/soap/encoding/",   false ); var schemacoll = assenc.schemaCollection; var schematype = schemacoll.getType(   "integer",   "http://www.w3.org/2001/XMLSchema" ); l.schemaType = schematype; u.schemaType = schematype; var parameters = [l, u]; 

Tip

First, see whether the Web Service works without this extra encoding. Older Mozilla versions do not support the getAssociatedEncoding() method, whereas some newer versions manage to cooperate with certain .NET Web Services without the extra step of providing the data type.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net