简体   繁体   English

如何将名称空间属性添加到ksoap信封?

[英]How to add namespace attribute to ksoap envelope?

I need to add an attribute (xmlns:n0="urn:checkOTP") to the envelope generated by ksoap2 (Android version). 我需要在ksoap2(Android版本)生成的信封中添加一个属性(xmlns:n0 =“urn:checkOTP”)。

<v:Envelope
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:d="http://www.w3.org/2001/XMLSchema"
  xmlns:c="http://www.w3.org/2003/05/soap-encoding"
  xmlns:v="http://www.w3.org/2003/05/soap-envelope">
  <v:Header>
  ...
</v:Envelope>

Turn to 转向

<v:Envelope
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:d="http://www.w3.org/2001/XMLSchema"
  xmlns:c="http://www.w3.org/2003/05/soap-encoding"
  xmlns:v="http://www.w3.org/2003/05/soap-envelope"
  xmlns:n0="urn:checkOTP">
  <v:Header>
   ...
  </v:Envelope>

the error code is: 错误代码是:

W/System.err(858): Code: SOAP-ENV:Sender, Reason: Method 'checkOtp' not implemented: method name or namespace not recognized

The server is a gSOAP2 one, and work perfectly if "xmlns:n0="urn:checkOTP" is added in the header (tested with javascript). 服务器是gSOAP2服务器,如果在标头中添加“xmlns:n0 =”urn:checkOTP“(使用javascript测试),则可以正常工作。

Best regards. 最好的祝福。

The following should work: 以下应该有效:

SoapObject request = new SoapObject("urn:checkOTP", "checkOTP")

That seems to add the namespace not to the envelope, but as an attribute to the method element inside the body element, but is also works however. 这似乎不是将命名空间添加到包络中,而是作为body元素内的method元素的属性,但也可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM