Android ksoap2 发送空信封?
我想寄一个空信封,如下所示:
<v:Envelope 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 />
<v:Body>
</v:Body>
</v:Envelope>
可以吗?如何发送?我尝试过这个:
HttpsTransportSE transport = new HttpsTransportSE(HOST, PORT, ENDPOINT, TIMEOUT);
SoapObject request = new SoapObject(null, null);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
transport.call(SOAP_ACTION, envelope);
我似乎不知道该怎么做,有人可以帮忙吗?
I want to send an envelope with an empty body like this:
<v:Envelope 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 />
<v:Body>
</v:Body>
</v:Envelope>
Is it possible and how? I've tried with this:
HttpsTransportSE transport = new HttpsTransportSE(HOST, PORT, ENDPOINT, TIMEOUT);
SoapObject request = new SoapObject(null, null);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
transport.call(SOAP_ACTION, envelope);
I can't seem to figure out how to do it, can anyone please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过创建自己的 SoapSerializationEnvelope 来扩展原始的 SoapSerializationEnvelope 并用以下方法重写 writeBody 方法,从而解决了该问题:
public class MySoapEnvelope extends SoapSerializationEnvelope
要使用它,您只需使用 MySoapSerializationEnvelope 并设置 Envelope.bodyOut=null;
我不知道你是否想用这段代码剪切一个新版本。我可能会在原始 SoapEnvelope 中创建一个名为 setEmptyEnvelope() 的新方法。但这取决于你。
你可以接受这个,但是你应该做一个受人尊敬的人
文档,以便人们知道这是如何完成的。
I have fixed the problem by creating my own SoapSerializationEnvelope extending the original one and overridering the writeBody method with this:
public class MySoapEnvelope extends SoapSerializationEnvelope
To use it, you just have to use the MySoapSerializationEnvelope and set envelope.bodyOut=null;
I dont know if you want to cut a new release with this code. I would possibly make a new method in the original SoapEnvelope called setEmptyEnvelope(). But that's up to you.
You could get along with this, but then you should make a respectable
documentation so people would know this is how it's done.
有趣的。您可能想要调试框架以查看发生了什么。如果您可以为其创建修复程序,我很乐意将其拉入上游并发布新版本。
Interesting. You might want to debug into the framework to see what is going on. If you can create a fix for it I am happy to pull it into upstream and cut a new release.