获取java.lang.illegalstateexception:连接未打开

0vvn1miw  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(300)

当我的代码试图访问第三方端点时,出现以下错误此请求是通过服务存根生成的代码发送的,我们使用的是axis2版本1.7.7
原因:java.lang.illegalstateexception:org.apache.commons.httpclient.httpconnection.assertopen(httpconnection)上的连接未打开。java:1277)位于org.apache.commons.httpclient.httpconnection.getresponseinputstream(httpconnection。java:858)在org.apache.commons.httpclient.multi-threadedhttpconnectionmanager$httpconnectionadapter.getresponseinputstream(多线程httpconnectionmanager。java:1297)
这可能是什么原因,我们如何解决这个问题。
以下代码供参考

public  com.test.Token validateToken(com.test.Token actionToken)throws java.rmi.RemoteException
{
org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
try{
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName());
_operationClient.getOptions().setAction("http://serviceURL/action");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&");
org.apache.axiom.soap.SOAPEnvelope env = null;

env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
actionToken,
optimizeContent(new javax.xml.namespace.QName("http://serviceURL", "action")),
new javax.xml.namespace.QName("http://serviceURL", "action"));

_serviceClient.addHeadersToEnvelope(env);
_messageContext.setEnvelope(env);

_operationClient.addMessageContext(_messageContext);

_operationClient.execute(true);
org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();

java.lang.Object object = fromOM(
_returnEnv.getBody().getFirstElement() ,
com.test.Token.class);

return (com.test.Token)object;
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题