How to set SOAP Header using KSOAP on Android

寵の児 提交于 2019-12-11 09:28:53

问题


I am struggling to set header fields to SOAP envelop with KSOAP2. I am following this tutorial http://code.tutsplus.com/tutorials/consuming-web-services-with-ksoap--mobile-21242

This is how the soap envelop looks like

<soap:Header>
<Authentication xmlns="http://tempuri.org/">
  <User>string</User>
  <Password>string</Password>
</Authentication>
</soap:Header>
<soap:Body>
< NewRegistration xmlns="http://tempuri.org/">
  <Title>string</Title>
  <FirstName>string</FirstName>
  <LastName>string</LastName>
</NewRegistration>
</soap:Body>
</soap:Envelope>

This is how the SOAPCaller class looks like

public String getCelsiusConversion(String fValue) {
String data = null;
String methodname = "NewRegistration";

SoapObject request = new SoapObject(NAMESPACE, methodname);
request.addProperty("Title", "");
request.addProperty("FirstName", "");
request.addProperty("LastName", "");

SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);

HttpTransportSE ht = getHttpTransportSE();
try {
    ht.call(SOAP_ACTION + methodname, envelope);
    testHttpResponse(ht);
    SoapPrimitive resultsString = (SoapPrimitive)envelope.getResponse();

    data = resultsString.toString();

} catch (SocketTimeoutException t) {
    t.printStackTrace();
} catch (IOException i) {
    i.printStackTrace();
} catch (Exception q) {
    q.printStackTrace();
}
return data;

}

How do I add the soap Header to soap envelop?

来源:https://stackoverflow.com/questions/29231074/how-to-set-soap-header-using-ksoap-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!