Android 向soap请求添加xml前缀
如何使用ksoap向soap添加前缀标记? 我想添加:xmlns:cnx=”http://db.hutt.com"Android 向soap请求添加xml前缀,android,soapui,ksoap2,android-ksoap2,Android,Soapui,Ksoap2,Android Ksoap2,如何使用ksoap向soap添加前缀标记? 我想添加:xmlns:cnx=”http://db.hutt.com" 塔特 tutt@12345 1. 因此,无论您使用哪种标记,例如:v:Envelope或soapenv:Envelope都无关紧要。soapserver将自动解析它。此外,要在xml信封中添加前缀,您需要扩展类SoapSerializationEnvelope 编辑之后,您的请求似乎是等价的。您希望更改什么?ttid元素可能不属于名称空间。您可以使用方法:public SoapO
塔特
tutt@12345
1.
因此,无论您使用哪种标记,例如:v:Envelope或soapenv:Envelope都无关紧要。soapserver将自动解析它。此外,要在xml信封中添加前缀,您需要扩展类SoapSerializationEnvelope
编辑之后,您的请求似乎是等价的。您希望更改什么?ttid元素可能不属于名称空间。您可以使用方法:public SoapObject addProperty(字符串名称空间、字符串名称、对象值)添加ttid元素,并将名称空间设置为空字符串。@KarelHusa我已编辑了该问题。我可以看到标题不应该有一些标签,而正文中的请求应该有标签。你能显示输入和期望的输出吗?使用groovy脚本可以吗?@Rao谢谢。我找到了解决办法。
<v:Envelope xmlns:cnx="http://db.hutt.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header>
<authentication xmlns:n0="http://db.hutt.com">
<userName>tutt</userName>
<password>tutt@12345</password>
</authentication>
</v:Header>
<v:Body>
<cnx:get_tt xmlns="">
<ttid>1</ttid>
</cnx:get_tt>
</v:Body>
</v:Envelope>
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
/**
* Created by suamatya on 4/11/2017.
*/
public class CustomSoapSerializationEnvelope extends SoapSerializationEnvelope {
CustomSoapSerializationEnvelope(int version){
super(version);
}
@Override
public void write(XmlSerializer writer) throws IOException {
writer.setPrefix("i", xsi);
writer.setPrefix("d", xsd);
writer.setPrefix("c", enc);
writer.setPrefix("v", env);
writer.setPrefix("db","http://db.hott.com");
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writeBody(writer);
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
}
}