I am using Axis2 to write a Client for a Webservice hosted on a remote server:
public static void getUserProfile(
final VSIUserServiceDetailsWebService_v5R0Stub stub) {
try {
final GetUserProfileByVOLNameDocument reqDoc =
GetUserProfileByVOLNameDocument.Factory.newInstance();
final GetUserProfileByVOLNameDocument.GetUserProfileByVOLName req =
reqDoc.addNewGetUserProfileByVOLName();
req.setString("resc3ofw");
LOG.debug("Invoking Web service...");
final GetUserProfileByVOLNameResponseDocument res =
stub.getUserProfileByVOLName(reqDoc);
LOG.debug("Output: "
+ res.getGetUserProfileByVOLNameResponse().getResult()
.getUserProfiles().getId());
} catch (final Exception e) {
LOG.error("Error! : ", e);
}
}
and I am getting an Exception "java.lang.IllegalArgumentException: Null OutputStream specified" Following is the complete trace of the log:
17:09:09.752 DEBUG [TestClient.getPrice():72] - Invoking Web service... 17:09:09.799 DEBUG [OutInAxisOperationClient.executeImpl():162] - Entry: OutInAxisOperationClient::execute, true 17:09:09.799 DEBUG [Phase.invoke():269] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking pre-condition for Phase "OperationOutPhase" 17:09:09.799 DEBUG [Phase.invoke():282] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Invoking phase "OperationOutPhase" 17:09:09.799 DEBUG [Phase.invoke():303] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking post-conditions for phase "OperationOutPhase" 17:09:09.799 DEBUG [Phase.invoke():269] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking pre-condition for Phase "RMPhase" 17:09:09.799 DEBUG [Phase.invoke():282] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Invoking phase "RMPhase" 17:09:09.799 DEBUG [Phase.invoke():303] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking post-conditions for phase "RMPhase" 17:09:09.799 DEBUG [Phase.invoke():269] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking pre-condition for Phase "PolicyDetermination" 17:09:09.799 DEBUG [Phase.invoke():282] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Invoking phase "PolicyDetermination" 17:09:09.799 DEBUG [Phase.invoke():303] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking post-conditions for phase "PolicyDetermination" 17:09:09.799 DEBUG [Phase.invoke():269] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking pre-condition for Phase "MessageOut" 17:09:09.799 DEBUG [Phase.invoke():282] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Invoking phase "MessageOut" 17:09:09.799 DEBUG [Phase.invoke():303] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking post-conditions for phase "MessageOut" 17:09:09.799 DEBUG [Phase.invoke():269] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking pre-condition for Phase "Security" 17:09:09.799 DEBUG [Phase.invoke():282] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Invoking phase "Security" 17:09:09.799 DEBUG [Phase.invoke():303] - [MessageContext: logID=urn:uuid:D5D2E12E5AB334EF381285587549833] Checking post-conditions for phase "Security" 17:09:09.846 DEBUG [SOAPMessageFormat开发者_如何学Pythonter.getContentType():122] - contentType from the OMOutputFormat =text/xml 17:09:09.846 DEBUG [SOAPMessageFormatter.getContentType():137] - contentType returned =text/xml; charset=UTF-8 17:09:09.861 DEBUG [AbstractHTTPSender.getHostConfiguration():272] - ProxyConfiguration 17:09:09.892 DEBUG [Wire.wire():84] - >> "CONNECT wsgateway2.XXX.com:443 HTTP/1.1" 17:09:09.892 DEBUG [Wire.wire():70] - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - >> "Host: wsgateway2.XXX.com[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - >> "Proxy-Connection: Keep-Alive[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - >> "[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - << "HTTP/1.1 200 Connection established.[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - << "HTTP/1.1 200 Connection established.[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - << "X-Junk: xxxxxxxxxxxxxx[\r][\n]" 17:09:09.892 DEBUG [Wire.wire():70] - << "[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "POST /VSIUserServiceDetailsWebService_v5r0 HTTP/1.1[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "Content-Type: text/xml; charset=UTF-8[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "SOAPAction: ""[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "User-Agent: Axis2[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "Host: wsgateway2.XXX.com[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "Transfer-Encoding: chunked[\r][\n]" 17:09:10.174 DEBUG [Wire.wire():70] - >> "[\r][\n]" 17:09:10.174 DEBUG [SOAPMessageFormatter.writeTo():49] - start writeTo() 17:09:10.174 DEBUG [SOAPMessageFormatter.writeTo():50] - preserve=false 17:09:10.174 DEBUG [SOAPMessageFormatter.writeTo():51] - isOptimized=false 17:09:10.174 DEBUG [SOAPMessageFormatter.writeTo():52] - isDoingSWA=false 17:09:10.189 DEBUG [StAXUtils.createXMLStreamWriter():251] - XMLStreamWriter is com.sun.xml.internal.stream.writers.XMLStreamWriterImpl 17:09:10.189 DEBUG [OMSourcedElementImpl.internalSerializeAndConsume():594] - serialize {http://netservices.XXX.net/vasipvsi/vsi_servicedetails_webservice}getUserProfileByVOLName to XMLStreamWriter 17:09:10.189 DEBUG [SOAPMessageFormatter.writeTo():75] - end writeTo() 17:09:10.564 ERROR [TestClient.getPrice():80] - Error! : java.lang.IllegalArgumentException: Null OutputStream specified at org.apache.xmlbeans.impl.store.Cursor._save(Cursor.java:577) at org.apache.xmlbeans.impl.store.Cursor.save(Cursor.java:2544) at org.apache.xmlbeans.impl.values.XmlObjectBase.save(XmlObjectBase.java:212) at net.XXX.web.wsclient.VSIUserServiceDetailsWebService_v5R0Stub$19.serialize(VSIUserServiceDetailsWebService_v5R0Stub.java:2735) at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerializeAndConsume(OMSourcedElementImpl.java:599) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:785) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:814) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:237) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:225) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume(OMElementImpl.java:814) at org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume(OMNodeImpl.java:421) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:68) at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:520) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:191) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163) at net.XXX.web.wsclient.VSIUserServiceDetailsWebService_v5R0Stub.getUserProfileByVOLName(VSIUserServiceDetailsWebService_v5R0Stub.java:1362) at net.XXX.web.wsclient.TestClient.getPrice(TestClient.java:74) at net.XXX.web.wsclient.TestClient.main(TestClient.java:41)
I have figured out myself what the issue was.
First I should extend
org.apache.axis2.transport.CommonsHTTPTransportSender
class instead of implementing
org.apache.axis2.transport.TransportSender
and then provide
super.invoke
in the overrridden invoke method to allow super class to handle the flow (Null outputstream error thrown becuase of the omission of this line).
I encountered the same error and it took a few days to get it resolved. To fix the problem I had to use the correct mix of dependencies in my pom.xml. Here is what I used that actually worked. Unfortunately, I had to use a slightly older version of some APIs:
<!-- SOAP client -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId> org.apache.ws.commons.neethi</groupId >
<artifactId> neethi</artifactId >
<version> 2.0.1</version >
</dependency>
I got the same exception when deploying an AMP to Alfresco. The code ran fine locally, but not when deployed in Alfresco. Turns out Alfresco already included its own version of the Axiom JARs. The version Alfresco uses is 1.2.5 and changing this to 1.2.7 solves the problem.
精彩评论