如何设置 SOAP 调用超时
我需要通过 HTTPS 使用 javax.xml.soap 为 SOAP 调用设置超时 但是我不知道该怎么做,一定有一个技巧可以做到这一点,但我找不到它。
SOAPMessage sm = null;
SOAPMessage response = null;
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory mf = MessageFactory.newInstance();
sm = mf.createMessage();
...
...
URL url = new URL("https://server:XXXX/blablabla);
response = connection.call(sm, url);
我看到有人在做:
if (xxxSoapService instanceof Stub)
((Stub) xxxSoapService).setTimeout(10000);
xxxSoapService extends java.rmi.Remote and Stub is from import org.apache.axis.client.Stub;
那里可能有我想念的东西。
I need to set a timeout to a SOAP call using javax.xml.soap over HTTPS
However I don't know how to do that, there must be a trick to do it but I could not find it.
SOAPMessage sm = null;
SOAPMessage response = null;
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory mf = MessageFactory.newInstance();
sm = mf.createMessage();
...
...
URL url = new URL("https://server:XXXX/blablabla);
response = connection.call(sm, url);
I saw someone doing:
if (xxxSoapService instanceof Stub)
((Stub) xxxSoapService).setTimeout(10000);
xxxSoapService extends java.rmi.Remote and Stub is from import org.apache.axis.client.Stub;
There is probably something I am missing there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您已经在后台线程中执行 .call() 。您可以在不同的线程上触发计时器并终止加载线程。
或者,由于 SOAPMessage 拥有您的所有数据,因此您可以仅使用 HttpUrlConnection 发送消息。
这应该有效,除非我对 writeTo() 的行为有误解。
Assuming you're already doing your .call() in a background thread. You can have a timer fire on a different thread and kill the loading thread.
Alternately, since SOAPMessage has all of your data you can just use HttpUrlConnection to send the message.
This should work, unless I'm mistaken about the behavior of writeTo().