Donet's WebService
Browser Access test address: Http://192.168.4.17/JLWWS/sendCommand.asmx, appeared
Click the Getdevicevalue method that appears
The XML code is pasted again:
post/jlwws/sendcommand.asmx http/1.1host:192.168.4.17content-type:text/xml; Charset=utf-8content-length: Lengthsoapaction: "Http://tempuri.org/getDeviceValue"<?XML version= "1.0" encoding= "Utf-8"?><Soap:envelopeXmlns: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> <Getdevicevaluexmlns= "http://tempuri.org/"> <N>Int</N> <s>String</s> </Getdevicevalue> </Soap:body></Soap:envelope>http/1.1 okcontent-type:text/xml; charset=utf-8content-length:length<?XML version= "1.0" encoding= "Utf-8"?><Soap:envelopeXmlns: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> <Getdevicevalueresponsexmlns= "http://tempuri.org/"> <Getdevicevalueresult>String</Getdevicevalueresult> </Getdevicevalueresponse> </Soap:body></Soap:envelope>
And then
Java method:
PublicString cc () {string result= ""; Try{Service service=NewService (); Call Call=(call) Service.createcall (); Call.setoperationname (NewQName ("http://tempuri.org/"," Getdevicevalue ")); Call.addparameter (NewQName ("http://tempuri.org/"," N "), Org.apache.axis.encoding.XMLType.XSD_INT, Javax.xml.rpc.ParameterMode.IN); Call.addparameter (NewQName ("http://tempuri.org/"," s "), Org.apache.axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.IN); Call.settargetendpointaddress (NewURL ("Http://192.168.4.17/JLWWS/sendCommand.asmx")); Call.setusesoapaction (true); Call.setsoapactionuri ("Http://tempuri.org/getDeviceValue"); //Soapservice soap = new Soapservice (); //soap.setname ("SendCommand1"); //call.setsoapservice (soap);result = (String) Call.invoke (NewObject[] {"1", "AAAAAAAAA"}); SYSTEM.OUT.PRINTLN (result); }Catch(Exception e) {e.printstacktrace (); } returnresult; }
Note the red part of the above code. First, the namespace attention should not be written wrong; second, if the parameter is an INT type, set the value of the string when the parameter, (Addparameter still want to Org.apache.axis.encoding.XMLType.XSD_INT).
Refer to a post on the CSDN forum that says:
The error message is as follows:
Axisfault
FaultCode: {http://schemas.xmlsoap.org/soap/envelope/}client
Faultsubcode:
FaultString: The server was unable to read the request. ---> There was an error in the XML document (1, 582). ---> The input string is not in the correct format.
==================
Although the XML is
<soap:Body>
<pubclientlogin xmlns= "http://NewCap.com/NewCapecWebService/" >
<appid>int</appid>
</PubClientLogin>
</soap:Body>
But the incoming parameter is entered as a string type,
Call.addparameter (New QName (targetnamespace, "AppID"), xmltype.xsd_int, parametermode.in);
Call.invoke (New object[]{""})
Post Address: http://bbs.csdn.net/topics/360243982