4

试图指定一个自定义的肥皂标题。不确定如何填充 SoapEnvelope.headerOut 属性。

到目前为止我的代码?

String soapAction = serviceNamespace + "/SearchCustomer";
SoapObject rpc = new SoapObject(serviceNamespace, "SearchCustomers");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;

rpc.addProperty("searchBy", searchBy);
rpc.addProperty("groupBy", Integer.toString(groupBy));

这是标题 WSDL 提取...

<soap:Header>
 <MISHeader xmlns="http://NCBI/WS/CRM">
  <applicationName>string</applicationName>
  <userName>string</userName>
 </MISHeader>
</soap:Header>
4

1 回答 1

4

headerOut 是您需要构建的 Element[]。

像这样的东西

  Element usernameElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Username");
  usernameElement.addChild(Node.TEXT, username);
  Element passwordElement = new Element().createElement(OASIS_SECURITY_XSD_URL, "Password");
  passwordElement.addChild(Node.TEXT, password);

然后将其添加到数组中..

于 2010-11-17T18:03:46.060 回答