2010-09-27 14 views
1

J'utilise Axis2 écrire un client pour un service Web hébergé sur un serveur distant:Axis2 exception client: java.lang.IllegalArgumentException: Null OutputStream spécifié

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); 
    } 
} 

et je reçois une exception « java.lang .IllegalArgumentException: Null OutputStream spécifié » est la trace Après complète du journal:

17: 09: 09,752 DEBUG [TestClient.getPrice(): 72] - Invoquer service Web ... 17: 09: 09,799 DEBUG [ OutInAxisOperationClient.executeImpl(): 162] - Entrée: OutInAxisOperationClient :: execute, true 17: 09: 09.799 DEBU G [Phase.invoke(): 269] - [MessageContext: identificateur de journal = urn: uuid: D5D2E12E5E33EE383887587549833] Vérification de la pré-condition pour la phase "OperationOutPhase" 17: 09: 09.799 DEBUG [Phase.invoke(): 282] - [MessageContext : logID = urn: uuid: D5D2E12E5AB334EF381285587549833] Appel de la phase "OperationOutPhase" 17: 09: 09.799 DEBUG [Phase.invoke(): 303] - [MessageContext: idDID = urn: uuid: D5D2E12E5E333EF381285587549833] Vérification des post-conditions pour la phase "OperationOutPhase " 17: 09: 09.799 DEBUG [Phase.invoke(): 269] - [MessageContext: idDID = urn: uuid: D5D2E12E5E5AB334EF381285587549833] Vérification de la pré-condition pour la phase" RMPhase " 17: 09: 09.799 DEBUG [Phase.invoke (): 282] - [MessageContext: logID = urn: uuid: D5D2E12E5AB334EF381285587549833] Appel de la phase "RMPhase" 17: 09: 09.799 DEBUG [Phase.invoke(): 303] - [MessageContext: ID_log = urn: uuid: D5D2E12E5AB334EF381285587549833] Chec post-conditions de roi pour la phase "RMPhase" 17: 09: 09.799 DEBUG [Phase.invoke(): 269] - [MessageContext: idDID = urn: uuid: D5D2E12E5E5AB334EF381285587549833] Vérification de la condition préalable pour la phase "PolicyDetermination" 17:09 : 09.799 DEBUG [Phase.invoke(): 282] - [MessageContext: idDID = urn: uuid: D5D2E12E5E33ABE4AB334EF381285587549833] Appel de phase "PolicyDetermination" 17: 09: 09.799 DEBUG [Phase.invoke(): 303] - [MessageContext: ID_journal = urn: uuid: D5D2E12E5AB334EF381285587549833] Vérification des conditions postérieures pour la phase "PolicyDetermination" 17: 09: 09.799 DEBUG [Phase.invoke(): 269] - [MessageContext: idDID = urn: uuid: D5D2E12E5E333EF381285587549833] Vérification de la pré-condition pour Phase "MessageOut" 17: 09: 09.799 DEBUG [Phase.invoke(): 282] - [MessageContext: identificateur de journal = urn: uuid: D5D2E12E5E33ABE3EF381285587549833] Appel de la phase "MessageOut" 17:09:09. 799 DEBUG [Phase.invoke(): 303] - [MessageContext: identificateur de journal = urn: uuid: D5D2E12E5E33ABE4AB334EF381285587549833] Vérification de post-conditions pour la phase "MessageOut" 17: 09: 09.799 DEBUG [Phase.invoke(): 269] - [ MessageContext: idDID = urn: uuid: D5D2E12E5AB334EF381285587549833] Vérification de la pré-condition pour la phase "sécurité" 17: 09: 09.799 DEBUG [Phase.invoke(): 282] - [MessageContext: ID_log = urn: uuid: D5D2E12E5AB334EF381285587549833] Phase d'appel " Sécurité " 17: 09: 09.799 DEBUG [Phase.invoke(): 303] - [MessageContext: idDID = urn: uuid: D5D2E12E5E5AB334EF381285587549833] Vérification des post-conditions pour la phase" Sécurité " 17: 09: 09.846 DEBUG [SOAPMessageFormatter.getContentType(): 122] - contentType de OMOutputFormat = text/xml 17: 09: 09.846 DEBUG [SOAPMessageFormatter.getContentType(): 137] - contentType retourné = text/xml; charset = UTF-8 17: 09: 09.861 DEBUG [AbstractHTTPSender.getHostConfiguration(): 272] - ProxyConfiguration 17: 09: 09.892 DEBUG [Wire.wire(): 84] - >> "CONNECTER wsgateway2.XXX.com: 443 HTTP/1.1 " 17: 09: 09.892 DEBUG [Wire.wire(): 70] - >>" Utilisateur-Agent: Jakarta Commons-HttpClient/3.1 [\ r] [\ n] " 17: 09: 09.892 DEBUG [Wire.wire(): 70] - >> "Hôte: wsgateway2.XXX.com [\ r] [\ n]" 17: 09: 09.892 DEBUG [Wire.wire(): 70] - >> " Proxy-connexion: 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 Connexion établie. [\ R] [\ n]" 17: 09: 09.892 DEBUG [Wire.wire(): 70] - < < "HTTP/1.1 200 Connexion estab terminé.[\ r] [\ n] " 17: 09: 09.892 DEBUG [Wire.wire(): 70] - < <" X-Junk: xxxxxxxxxxxxxx [\ r] [\ n] " 17: 09: 09.892 DÉBOGAGE [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] - >>" Type de contenu: 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] - >> "Utilisateur-Agent: Axis2 [\ r] [\ n]" 17: 09: 10.174 DEBUG [Wire.wire(): 70] - >> "Hôte: wsgateway2.XXX.com [\ r] [\ n]" 17: 09: 10.174 DEBUG [Wire.wire(): 70] - >> "Transfert-Encodage: chunked [\ r] [\ n] " 17: 09: 10.174 DEBUG [Wire.wire(): 70] - >>" [\ r] [\ n] " 17: 09: 10.174 DEBUG [SOAPMessageFormatter.writeTo(): 49] - commence à writeTo () 17: 09: 10,174 DEBUG [SOAPMessageFormatter.writeTo(): 50] - préserver = 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 [St AXUtils.createXMLStreamWriter(): 251] - XMLStreamWriter est com.sun.xml.internal.stream.writers.XMLStreamWriterImpl 17: 09: 10.189 DEBUG [OMSourcedElementImpl.internalSerializeAndConsume(): 594] - sérialiser {http://netservices.XXX .net/vasipvsi/vsi_servicedetails_webservice} getUserProfileByVOLName à XMLStreamWriter 17: 09: 10,189 DEBUG [SOAPMessageFormatter.writeTo(): 75] - fin WriteTo() 17: 09: 10,564 ERROR [TestClient.getPrice(): 80] - erreur ! : java.lang.IllegalArgumentException: Null OutputStream spécifié à org.apache.xmlbeans.impl.store.Cursor._save (Cursor.java:577) à org.apache.xmlbeans.impl.store.Cursor. save (Cursor.java:2544) à org.apache.xmlbeans.impl.values.XmlObjectBase.save (XmlObjectBase.java:212) à net.XXX.web.wsclient.VSIUserServiceDetailsWebService_v5R0Stub $ 19.serialize (VSIUserServiceDetailsWebService_v5R0Stub.java:2735) à org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerializeAndConsume (OMSourcedElementImpl.java:599) à org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize (OMElementImpl.java:785) à org.apache.axiom.om.impl.llom.OMElementImpl .internalSerializeAndConsume (OMElementImpl.java:814) à org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally (SOAPEnvelopeImpl.java:237) à org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize (SOAPEnvelopeImpl.java:225) à org.apache.axiom.om.impl.llom.OMElementImpl.internalSerializeAndConsume (OMElementImpl.java:814) à org.apache.axiom.om.impl.llom.OMNodeImpl.serializeAndConsume (OMNodeImpl .java: 421) à org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo (SOAPMessageFormatter.java:68) à org.apache.axis2.transport.http.AxisRequestEntity.writeRequest (AxisRequestEntity.java:84) à org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody (EntityEnclosingMethod.java:499) à o rg.apache.commons.httpclient.HttpMethodBase.writeRequest (HttpMethodBase.java:2114) à org.apache.commons.httpclient.HttpMethodBase.execute (HttpMethodBase.java:1096) à org.apache.commons.httpclient.HttpMethodDirector. executeWithRetry (HttpMethodDirector.java:398) à org.apache.commons.httpclient.HttpMethodDirector.executeMethod (HttpMethodDirector.java:171) à org.apache.commons.httpclient.HttpClient.executeMethod (HttpClient.java:397) à org.apache.commons.httpclient.HttpClient.executeMethod (HttpClient.java:346) à org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod (AbstractHTTPSender.java:520) à org.apache.axis2.transport. http.HTTPSender.sendViaPost (HTTPSender.java:191) à org.apache.axis2.transport.http.HTTPSender.send (HTTPSender.java:77) à org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons (CommonsHTTPTransportSender.java: 327) à org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke (CommonsHTTPTransportSender.java:206) à org.apache.axis2.engine.AxisEngine.send (AxisEngine.java:396) à org.apache. axis2.description.OutInAxisOperationClient.send (OutInAxisOperation.java:374) à org.apache.axis2.description.OutInAxisOperationClient.executeImpl (OutInAxisOperation.java:211) à org.apache.axis2.client.OperationClient.execute (OperationClient. java: 163) à net.XXX.web.wsclient.VSIUserServiceDetailsWebService_v5R0Stub.getUserP rofileByVOLName (VSIUserServiceDetailsWebService_v5R0Stub.java:1362) à net.XXX.web.wsclient.TestClient.getPrice (TestClient.java:74) à net.XXX.web.wsclient.TestClient.main (TestClient.java:41)

Répondre

0

J'ai compris moi-même quel était le problème.

D'abord, je dois étendre

org.apache.axis2.transport.CommonsHTTPTransportSender

classe au lieu de mettre en œuvre

org.apache.axis2.transport.TransportSender

et le n fournir

super.invoke

dans le procédé overrridden d'invocation pour permettre à super-classe pour gérer le flux (d'erreur de la Null jeté becuase de l'omission de cette ligne).

0

J'ai rencontré la même erreur et il a fallu quelques jours pour la résoudre. Pour résoudre le problème, j'ai dû utiliser le bon mélange de dépendances dans mon fichier pom.xml. Voici ce que j'ai utilisé qui a réellement fonctionné. Malheureusement, je devais utiliser une version légèrement plus ancienne de certaines API:

<!-- 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> 
0

Je suis la même exception lors du déploiement d'une AMP à Alfresco. Le code fonctionnait correctement localement, mais pas lorsqu'il était déployé dans Alfresco. Il s'avère qu'Alfresco a déjà inclus sa propre version des JAR Axiom. La version utilisée par Alfresco est 1.2.5 et le passage à 1.2.7 résout le problème.