我想使用 .NET 制作的网络服务。为了生成我的源代码,我使用了基于 Web 服务的 WSDL 的 Axis2。我在没有选项的情况下启动了 Axis。
我可以调用webservice的第一个方法。这是网络服务的认证方法“连接”。在此之后,我再次调用了一个新方法,但网络服务表明我不再连接。Web服务的支持告诉我这是因为在我调用connect方法后,连接被java关闭了。而这个,网络服务假设我已断开连接并关闭我的会话。
为了解决这个问题,我对这两种方法的成功调用应该保持实时连接。但是,我不确定 Axis2 是否建议使用此功能,是真的吗?
如何保持不同呼叫之间的连接?
这是我的java代码:
WinbooksWebServiceStub stub = new WinbooksWebServiceStub("http://myUrl/Service.asmx");
Connect c = new Connect();
c.setKey("KEY");
c.setUser("USER");
c.setPass("PSW");
ConnectResponse resp = stub.connect(c);
ConnectParser connecterParser = new ConnectParser();//works and return the Token
HelloWorld h = new HelloWorld();
HelloWorldResponse Hresp = stub.helloWorld(h); //the result tell me that I'm not connected
如果我按照答案,我在我的存根对象上应用方法,我在线程“main”中得到这个错误异常
org.apache.axis2.AxisFault: Attempted read on closed stream.
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:64)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.logidrive.ws.WinbooksWebServiceStub.connect(WinbooksWebServiceStub.java:4251)
at Main.main(Main.java:44) Caused by: java.io.IOException: Attempted read on closed stream.
at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at org.apache.axiom.om.util.DetachableInputStream.read(DetachableInputStream.java:147)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at java.io.PushbackInputStream.read(PushbackInputStream.java:169)
at org.apache.axis2.builder.BuilderUtil.getCharSetEncoding(BuilderUtil.java:294)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:51)