-1
我想從soap webservice得到響應,但總是出現錯誤,請檢查我是否正確調用web服務。 以下是我的web在android中訪問soap web服務
<wsdl:definitions name="MobileeServiceWsd" targetNamespace="urn:MobileeServiceWsd"><wsdl:import location="http://vddp.dewa.gov.ae:50700/MobileeService/Config2/bindings?wsdl&style=document" namespace="urn:MobileeServiceWsd/Config2/document"/><wsdl:service name="MobileeService"><wsdl:port name="Config2Port_Document" binding="bns0:Config2Binding"><soap:address location="http://vddp.dewa.gov.ae:50700/MobileeService/Config2?style=document"/></wsdl:port></wsdl:service></wsdl:definitions>
的WSDL和下面是我的代碼。
private static final String METHOD_NAME = "getOutstandingBalance";
private static final String SOAP_ACTION = "MobileeService";
private static final String NAMESPACE = "MobileeServiceWsd/Config2/document";
private static final String URL = "http://vddp.dewa.gov.ae:50700/MobileeService/Config2/bindings?wsdl&style=document";
public SoapObject testMethod(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException
{
//List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true; //for .net services
envelope.bodyOut = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:MobileeServiceVi\">"+
"<soapenv:Header/>"+
"<soapenv:Body>"+
"<urn:getOutstandingBalance>"+
"<urn:contractaccount>000001000104</urn:contractaccount>"+
"<urn:mobileosver>ios 4.3</urn:mobileosver>"+
"<urn:appver>3.3</urn:appver>"+
"<urn:appidentifier>343534</urn:appidentifier>"+
"</urn:getOutstandingBalance>"+
"</soapenv:Body>"+
"</soapenv:Envelope>";
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
//httpTransport.call(SOAP_ACTION, envelope, headers);
httpTransport.call(SOAP_ACTION, envelope);
return (SoapObject) envelope.getResponse();
}
以及如何,這是從問題的代碼有什麼不同? – Selvin
以下鏈接適用於我https://groups.google.com/forum/#!topic/android-developers/sNwGyt9gHso –