我对soap webservice很新,我需要帮助......这是我的代码,我无法理解这个问题..请帮助....
private static String URL = "MYURL.asmx";
private static String SOAP_ACTION = "http://tempuri.org/methodname";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "methodname";
//Create request
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("parm1", "11111111");
request.addProperty("parm2", "111");
request.addProperty("parm3", "11");
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//Invole web service
androidHttpTransport.call(SOAP_ACTION, envelope);
if (envelope.bodyIn instanceof SoapFault) {
String str= ((SoapFault) envelope.bodyIn).faultstring;
Log.i("", str);
System.out.println("str!!!!!!!!!!!!! = " + str);
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Log.d("WS", String.valueOf(resultsRequestSOAP));
System.out.println("String.valueOf(resultsRequestSOAP)!!!!!!!!!! = " + String.valueOf(resultsRequestSOAP)+"");
}
} catch (Exception e) {
System.out.println("e.getMessage()!!!!!!!!!! = " + e.getMessage());
}
但我正在收到System.out:
str!!!!!!!!!!!!! = Server was unable to process request. ---> Object reference not set to an instance of an object.
这是我的ws
POST URL.asmx HTTP/1.1
Host: www.URL.in
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/METHODNAME"
<?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>
<GetTransactionStatus xmlns="http://tempuri.org/">
<req>
<param1xmlns="http://URL.net/smurl">int</param1>
</req>
<header>
<param2>string</param2>
<param3>string</param3>
</header>
</METHODNAME>
</soap:Body>
</soap:Envelope>