-->

如何在Android上使用KSOAP设置SOAP头(How to set SOAP Header u

2019-10-22 08:36发布

我奋力设置头字段与KSOAP2 SOAP信封。 我下面这个教程http://code.tutsplus.com/tutorials/consuming-web-services-with-ksoap--mobile-21242

这是SOAP信封的样子

<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>

这是SOAPCaller类的样子

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;

}

如何添加SOAP头肥皂信封?

文章来源: How to set SOAP Header using KSOAP on Android