Я пытаюсь вызвать следующий soap метод веб-сервиса в android:
POST /DataService.asmx HTTP/1.1
Host: public.server.de
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://server/soa/ping"
<?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:Header>
<UserCredentials xmlns="https://soa.server.de/soa/">
<userName>string</userName>
<password>string</password>
</UserCredentials>
</soap:Header>
<soap:Body>
<ping xmlns="https://soa.server.de/soa/">
<curPingRequest>
<input>string</input>
</curPingRequest>
</ping>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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.server.org/soap/envelope/">
<soap:Body>
<pingResponse xmlns="https://soa.server.de/soa/">
<pingResult>string</pingResult>
</pingResponse>
</soap:Body>
</soap:Envelope>
Мой подход в Android такой:
String SOAP_ACTION = "https://soa.server.de/soa/ping";
String METHOD_NAME = "ping";
String NAMESPACE = "https://soa.server.de/soa/";
String URL = "https://public.server.de/DataService.asmx";
try {
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("input","test");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
soapEnvelope.setOutputSoapObject(Request);
soapEnvelope.dotNet = true;
ArrayList<HeaderProperty> headerProperty = new ArrayList<HeaderProperty>();
headerProperty.add(new HeaderProperty("userName", "myUsername"));
headerProperty.add(new HeaderProperty("password", "myPassword"));
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE transport = new HttpTransportSE(URL);
transport.call(SOAP_ACTION, soapEnvelope, headerProperty);
resultString = (SoapPrimitive) soapEnvelope.getResponse();
К сожалению, я всегда получить исключение от сервера:
Код: AppException, Причина: ссылка на объект не была установлена для экземпляра объекта.
Есть идеи?