Blackberry kSoap2 & Soap Header

心不动则不痛 提交于 2019-11-29 15:19:42

问题


Trying to specify a custom soap header. Not sure how the SoapEnvelope.headerOut propery is to be populated.

My code so far?

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

Here is the header WSDL extract...

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

回答1:


headerOut is an Element[] that you need to build.

Something like this

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

and then add it to an array..



来源:https://stackoverflow.com/questions/4194920/blackberry-ksoap2-soap-header

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