web-dev-qa-db-fra.com

Exception de client CXF: l'intercepteur pour {XXX} a levé une exception, se déroulant maintenant

Je rencontre cette exception CXF suivante:

warning: Interceptor for {http://example.com/wsdl/esc/2011-12-12/}AmazonEC2#{http://example.com/wsdl/esc/2011-12-12/}NewDescribeImages has thrown exception, unwinding now
Java.lang.NullPointerException
    at org.Apache.cxf.binding.soap.interceptor.StartBodyInterceptor.handleMessage(StartBodyInterceptor.Java:59)
    at org.Apache.cxf.binding.soap.interceptor.StartBodyInterceptor.handleMessage(StartBodyInterceptor.Java:37)
    at org.Apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.Java:263)
    at org.Apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.Java:762)
    at org.Apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.Java:1582)
    at org.Apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.Java:1467)
    at org.Apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.Java:1375)
    at org.Apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.Java:47)
    at org.Apache.cxf.io.CachedOutputStream.close(CachedOutputStream.Java:188)
    at org.Apache.cxf.transport.AbstractConduit.close(AbstractConduit.Java:56)
    at org.Apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.Java:623)
    at org.Apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.Java:62)
    at org.Apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.Java:263)
    at org.Apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.Java:510)
    at org.Apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.Java:440)
    at org.Apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.Java:343)
    at org.Apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.Java:295)
    at org.Apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.Java:73)
    at org.Apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.Java:124)
    at $Proxy31.newDescribeImages(Unknown Source)
    at test.App.main(App.Java:62)
javax.xml.ws.soap.SOAPFaultException: Fault string, and possibly fault code, not set

le code qui provoque cette exception:

    MyService ms =new MyService ();
    MyServicePort port = ms.getAmazonEC2Port();
    BindingProvider bp = (BindingProvider) port;
    bp.getRequestContext()
            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                    "http://192.180.33.12:8773/services/myservice_url/");

    Client client = ClientProxy.getClient(portType);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    Endpoint endpoint = client.getEndpoint();

    Map<String, Object> inProps=new HashMap<String, Object>();
    Map<String,Object> outProps = new HashMap<String,Object>();
    configWSProps(inProps, outProps); //here is some WS-Security properties

    WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);

    endpoint.getInInterceptors().add(wssIn);
    endpoint.getOutInterceptors().add(wssOut);

    SomeResponseType response = port.someMethod();

Cette exception est renvoyée dans la dernière ligne: port.someMethod () . Dans la méthode configWSProps (...), je définis certaines propriétés de WS-Security, il est peu probable qu’il y ait un problème ici.

J'ai imprimé les journaux cxf, je peux voir que le message entrant contient les données correctes.

D'après le code source de CXF, il semble que CXF ne puisse pas récupérer le message soap, mais je ne sais pas comment résoudre ce problème. Aidez-moi, s'il vous plaît!

voici le code source CXF: http://grepcode.com/file/repo1.maven.org/maven2/org.Apache.cxf/cxf-rt-bindings-soap/2.4.1/org/ Apache/cxf/binding/soap/interceptor/StartBodyInterceptor.Java/# 59

13
Wint

Après avoir débogué dans le code cxf et cherché de l'aide dans la liste de diffusion cxf, j'ai finalement résolu ce problème. Le problème est dû au message entrant, l’en-tête de type de contenu n’a pas l’en-tête de contenu, ce qui empêche CXF de créer un XMLStreamReader, puis de lire le contenu. Une exception NullPointerException est alors levée. merci aux gars de la communauté CXF!

J'ai posé une question et j'ai obtenu une réponse à ce sujet: http://cxf.547215.n5.nabble.com/CXF-client-exception-Interceptor-for-XXX-has-thrown-exception-unwinding-now- td5449373.html # a5449764

15
Wint

Assurez-vous que le noeud final est correct ou accessible via cet environnement dans lequel le composant a été déployé.

Peut-être que ce serait un problème de proxy qui ne passe pas le noeud final.

0
Ajay