You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Julien Taillard <ju...@alicante.fr> on 2013/04/05 13:18:48 UTC

Problem while reading soap response

Hello,

I'm facing a problem using CXF 2.7.4 to build a client for a Metro 
Secured WebService.
Client library is generated using the wsdl2java tool.

Calling a simple helloworld service, I get null result while SOAP 
response message seems correct.
     System.out.println(fuzzimpl.sayHello());

SayHello method Signature:
     public String sayHello();

The SOAP response message:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope 
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security 
S:mustUnderstand="1"><wsu:Timestamp 
xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" 
xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" 
wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse 
xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>

Do you have an idea of what append and how to solve it?

Thanks and Regards,
Julien

Global Trace:

INFO: Outbound Message
---------------------------
ID: 1
Address: https://localhost:8443/FuzzWSService
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
soap:mustUnderstand="1"><wsse:UsernameToken 
wsu:Id="UsernameToken-1"><wsse:Username>test</wsse:Username><wsse:Password 
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password><wsse:Nonce 
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">d3dmAYHNdMTpnVcDraYofw==</wsse:Nonce><wsu:Created>2013-04-05T10:39:49.701Z</wsu:Created></wsse:UsernameToken></wsse:Security><Action 
xmlns="http://www.w3.org/2005/08/addressing">http://impl.services.fuzzws.alicante.fr/FuzzWSImplPortType/sayHello</Action><MessageID 
xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:c351d89f-0c92-4483-998f-c553a228000a</MessageID><To 
xmlns="http://www.w3.org/2005/08/addressing">https://localhost:8443/FuzzWSService</To><ReplyTo 
xmlns="http://www.w3.org/2005/08/addressing"><Address>http://www.w3.org/2005/08/addressing/anonymous</Address></ReplyTo></soap:Header><soap:Body><ns1:sayHello 
xmlns:ns1="http://impl.services.fuzzws.alicante.fr/"/></soap:Body></soap:Envelope>
--------------------------------------
5 avr. 2013 12:39:49 
org.apache.cxf.services.FuzzWSImpl.FuzzWSImplPort.FuzzWSImplPortType
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {content-type=[text/xml;charset=UTF-8], 
Server=[Jetty(8.0.1.v20110908)], transfer-encoding=[chunked]}
Payload: <?xml version='1.0' encoding='UTF-8'?><S:Envelope 
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security 
S:mustUnderstand="1"><wsu:Timestamp 
xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" 
xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" 
wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse 
xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>
--------------------------------------
null

Sample code for the client:

             ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
             factory.setServiceClass(FuzzWSImpl.class);
             factory.setAddress("https://localhost:8443/FuzzWSService");

             FuzzWSImpl fuzzimpl = (FuzzWSImpl) factory.create();

             Client cxfClient = ClientProxy.getClient(fuzzimpl);
             //Log SOAP message
             cxfClient.getInInterceptors().add(new LoggingInInterceptor());
             cxfClient.getOutInterceptors().add(new 
LoggingOutInterceptor());
             //Set Http conduit
             HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
             TLSClientParameters param = new TLSClientParameters();
             param.setDisableCNCheck(true);
             http.setTlsClientParameters(param);

             //Set properties
             Map<String, Object> outProps = new HashMap<String, Object>();
             //Set userName token action
             outProps.put(WSHandlerConstants.ACTION, 
WSHandlerConstants.USERNAME_TOKEN);
             // Set username
             outProps.put(WSHandlerConstants.USER, "test");
             // Password type : plain text
             outProps.put(WSHandlerConstants.PASSWORD_TYPE, 
WSConstants.PW_TEXT);
             // for hashed password use:
             //properties.put(WSHandlerConstants.PASSWORD_TYPE, 
WSConstants.PW_DIGEST);
             // Callback used to retrieve password for given user.
             outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
             ClientPasswordCallback.class.getName());
             //Add nonce and created timestamp
             outProps.put(WSHandlerConstants.ADD_UT_ELEMENTS, 
WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);

             //Enable web securiry
             WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
             cxfClient.getEndpoint().getOutInterceptors().add(wssOut);
             //For addressing
             cxfClient.getEndpoint().getOutInterceptors().add(new 
org.apache.cxf.ws.addressing.MAPAggregator());
             cxfClient.getEndpoint().getOutInterceptors().add(new 
org.apache.cxf.ws.addressing.soap.MAPCodec());

             //sayHello
             System.out.println(fuzzimpl.sayHello());


RE: Problem while reading soap response

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Could you provide part of WSDL with definition of sayHelloResponse element and appropriate message?

Regards,
Andrei.

> -----Original Message-----
> From: Julien Taillard [mailto:julien.taillard@alicante.fr]
> Sent: Freitag, 5. April 2013 13:19
> To: users@cxf.apache.org
> Subject: Problem while reading soap response
> 
> Hello,
> 
> I'm facing a problem using CXF 2.7.4 to build a client for a Metro Secured
> WebService.
> Client library is generated using the wsdl2java tool.
> 
> Calling a simple helloworld service, I get null result while SOAP response
> message seems correct.
>      System.out.println(fuzzimpl.sayHello());
> 
> SayHello method Signature:
>      public String sayHello();
> 
> The SOAP response message:
> <?xml version='1.0' encoding='UTF-8'?><S:Envelope
> xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-utility-1.0.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Securi
> ty
> S:mustUnderstand="1"><wsu:Timestamp
> xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-
> secureconversation/200512"
> xmlns:ns13="http://www.w3.org/2003/05/soap-envelope"
> wsu:Id="_1"><wsu:Created>2013-04-
> 05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-
> 05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header
> ><S:Body><ns2:sayHelloResponse
> xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:
> hello></ns2:sayHelloResponse></S:Body></S:Envelope>
> 
> Do you have an idea of what append and how to solve it?
> 
> Thanks and Regards,
> Julien
> 
> Global Trace:
> 
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: https://localhost:8443/FuzzWSService
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: text/xml
> Headers: {Accept=[*/*], SOAPAction=[""]}
> Payload: <soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header>
> <wsse:Security
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-utility-1.0.xsd"
> soap:mustUnderstand="1"><wsse:UsernameToken
> wsu:Id="UsernameToken-
> 1"><wsse:Username>test</wsse:Username><wsse:Password
> Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> username-token-profile-
> 1.0#PasswordText">test</wsse:Password><wsse:Nonce
> EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> soap-message-security-
> 1.0#Base64Binary">d3dmAYHNdMTpnVcDraYofw==</wsse:Nonce><wsu:Cr
> eated>2013-04-
> 05T10:39:49.701Z</wsu:Created></wsse:UsernameToken></wsse:Security>
> <Action
> xmlns="http://www.w3.org/2005/08/addressing">http://impl.services.fuzz
> ws.alicante.fr/FuzzWSImplPortType/sayHello</Action><MessageID
> xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:c351d89f-0c92-
> 4483-998f-c553a228000a</MessageID><To
> xmlns="http://www.w3.org/2005/08/addressing">https://localhost:8443/Fu
> zzWSService</To><ReplyTo
> xmlns="http://www.w3.org/2005/08/addressing"><Address>http://www.w
> 3.org/2005/08/addressing/anonymous</Address></ReplyTo></soap:Header
> ><soap:Body><ns1:sayHello
> xmlns:ns1="http://impl.services.fuzzws.alicante.fr/"/></soap:Body></soap:
> Envelope>
> --------------------------------------
> 5 avr. 2013 12:39:49
> org.apache.cxf.services.FuzzWSImpl.FuzzWSImplPort.FuzzWSImplPortType
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: text/xml;charset=UTF-8
> Headers: {content-type=[text/xml;charset=UTF-8],
> Server=[Jetty(8.0.1.v20110908)], transfer-encoding=[chunked]}
> Payload: <?xml version='1.0' encoding='UTF-8'?><S:Envelope
> xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
> wssecurity-utility-1.0.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Securi
> ty
> S:mustUnderstand="1"><wsu:Timestamp
> xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-
> secureconversation/200512"
> xmlns:ns13="http://www.w3.org/2003/05/soap-envelope"
> wsu:Id="_1"><wsu:Created>2013-04-
> 05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-
> 05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header
> ><S:Body><ns2:sayHelloResponse
> xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:
> hello></ns2:sayHelloResponse></S:Body></S:Envelope>
> --------------------------------------
> null
> 
> Sample code for the client:
> 
>              ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>              factory.setServiceClass(FuzzWSImpl.class);
>              factory.setAddress("https://localhost:8443/FuzzWSService");
> 
>              FuzzWSImpl fuzzimpl = (FuzzWSImpl) factory.create();
> 
>              Client cxfClient = ClientProxy.getClient(fuzzimpl);
>              //Log SOAP message
>              cxfClient.getInInterceptors().add(new LoggingInInterceptor());
>              cxfClient.getOutInterceptors().add(new
> LoggingOutInterceptor());
>              //Set Http conduit
>              HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
>              TLSClientParameters param = new TLSClientParameters();
>              param.setDisableCNCheck(true);
>              http.setTlsClientParameters(param);
> 
>              //Set properties
>              Map<String, Object> outProps = new HashMap<String, Object>();
>              //Set userName token action
>              outProps.put(WSHandlerConstants.ACTION,
> WSHandlerConstants.USERNAME_TOKEN);
>              // Set username
>              outProps.put(WSHandlerConstants.USER, "test");
>              // Password type : plain text
>              outProps.put(WSHandlerConstants.PASSWORD_TYPE,
> WSConstants.PW_TEXT);
>              // for hashed password use:
>              //properties.put(WSHandlerConstants.PASSWORD_TYPE,
> WSConstants.PW_DIGEST);
>              // Callback used to retrieve password for given user.
>              outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
>              ClientPasswordCallback.class.getName());
>              //Add nonce and created timestamp
>              outProps.put(WSHandlerConstants.ADD_UT_ELEMENTS,
> WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);
> 
>              //Enable web securiry
>              WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
>              cxfClient.getEndpoint().getOutInterceptors().add(wssOut);
>              //For addressing
>              cxfClient.getEndpoint().getOutInterceptors().add(new
> org.apache.cxf.ws.addressing.MAPAggregator());
>              cxfClient.getEndpoint().getOutInterceptors().add(new
> org.apache.cxf.ws.addressing.soap.MAPCodec());
> 
>              //sayHello
>              System.out.println(fuzzimpl.sayHello());


Re: Problem while reading soap response

Posted by Julien Taillard <ju...@alicante.fr>.
Thanks you, it works fine using the JAX-WS frontend.

Julien

On 05/04/2013 16:20, Daniel Kulp wrote:
> On Apr 5, 2013, at 7:18 AM, Julien Taillard<ju...@alicante.fr>  wrote:
>
>> Hello,
>>
>> I'm facing a problem using CXF 2.7.4 to build a client for a Metro Secured WebService.
>> Client library is generated using the wsdl2java tool.
> If you are using the wsdl2java tool, you most likely need to use the JAX-WS frontend.   Change:
>
>>    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
> to
>
>>    ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>
> and that may help.
>
>
> Dan
>
>
>
>
>> Calling a simple helloworld service, I get null result while SOAP response message seems correct.
>>     System.out.println(fuzzimpl.sayHello());
>>
>> SayHello method Signature:
>>     public String sayHello();
>>
>> The SOAP response message:
>> <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security S:mustUnderstand="1"><wsu:Timestamp xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>
>>
>> Do you have an idea of what append and how to solve it?
>>
>> Thanks and Regards,
>> Julien
>>
>> Global Trace:
>>
>> INFO: Outbound Message
>> ---------------------------
>> ID: 1
>> Address: https://localhost:8443/FuzzWSService
>> Encoding: UTF-8
>> Http-Method: POST
>> Content-Type: text/xml
>> Headers: {Accept=[*/*], SOAPAction=[""]}
>> Payload:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken wsu:Id="UsernameToken-1"><wsse:Username>test</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">d3dmAYHNdMTpnVcDraYofw==</wsse:Nonce><wsu:Created>2013-04-05T10:39:49.701Z</wsu:Created></wsse:UsernameToken></wsse:Security><Action xmlns="http://www.w3.org/2005/08/addressing">http://impl.services.fuzzws.alicante.fr/FuzzWSImplPortType/sayHello</Action><MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:c351d89f-0c92-4483-998f-c553a228000a</MessageID><To xmlns="http://www.w3.org/2005/08/addressing">https://localhost:8443/FuzzWSService</To><ReplyTo xmlns="http://www.w3.org/2005/08/addressing"><Address>http://www.w3.org/2005/08/addressing/anonymous</Address></ReplyTo></soap:Header><soap:Body><ns1:sayHello xmlns:ns1="http://impl.services.fuzzws.alicante.fr/"/></soap:Body></soap:Envelope>
>> --------------------------------------
>> 5 avr. 2013 12:39:49 org.apache.cxf.services.FuzzWSImpl.FuzzWSImplPort.FuzzWSImplPortType
>> INFO: Inbound Message
>> ----------------------------
>> ID: 1
>> Response-Code: 200
>> Encoding: UTF-8
>> Content-Type: text/xml;charset=UTF-8
>> Headers: {content-type=[text/xml;charset=UTF-8], Server=[Jetty(8.0.1.v20110908)], transfer-encoding=[chunked]}
>> Payload:<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security S:mustUnderstand="1"><wsu:Timestamp xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>
>> --------------------------------------
>> null
>>
>> Sample code for the client:
>>
>>             ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>>             factory.setServiceClass(FuzzWSImpl.class);
>>             factory.setAddress("https://localhost:8443/FuzzWSService");
>>
>>             FuzzWSImpl fuzzimpl = (FuzzWSImpl) factory.create();
>>
>>             Client cxfClient = ClientProxy.getClient(fuzzimpl);
>>             //Log SOAP message
>>             cxfClient.getInInterceptors().add(new LoggingInInterceptor());
>>             cxfClient.getOutInterceptors().add(new LoggingOutInterceptor());
>>             //Set Http conduit
>>             HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
>>             TLSClientParameters param = new TLSClientParameters();
>>             param.setDisableCNCheck(true);
>>             http.setTlsClientParameters(param);
>>
>>             //Set properties
>>             Map<String, Object>  outProps = new HashMap<String, Object>();
>>             //Set userName token action
>>             outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
>>             // Set username
>>             outProps.put(WSHandlerConstants.USER, "test");
>>             // Password type : plain text
>>             outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
>>             // for hashed password use:
>>             //properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
>>             // Callback used to retrieve password for given user.
>>             outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
>>             ClientPasswordCallback.class.getName());
>>             //Add nonce and created timestamp
>>             outProps.put(WSHandlerConstants.ADD_UT_ELEMENTS, WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);
>>
>>             //Enable web securiry
>>             WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
>>             cxfClient.getEndpoint().getOutInterceptors().add(wssOut);
>>             //For addressing
>>             cxfClient.getEndpoint().getOutInterceptors().add(new org.apache.cxf.ws.addressing.MAPAggregator());
>>             cxfClient.getEndpoint().getOutInterceptors().add(new org.apache.cxf.ws.addressing.soap.MAPCodec());
>>
>>             //sayHello
>>             System.out.println(fuzzimpl.sayHello());
>>



Re: Problem while reading soap response

Posted by Daniel Kulp <dk...@apache.org>.
On Apr 5, 2013, at 7:18 AM, Julien Taillard <ju...@alicante.fr> wrote:

> Hello,
> 
> I'm facing a problem using CXF 2.7.4 to build a client for a Metro Secured WebService.
> Client library is generated using the wsdl2java tool.

If you are using the wsdl2java tool, you most likely need to use the JAX-WS frontend.   Change:

>   ClientProxyFactoryBean factory = new ClientProxyFactoryBean();

to 

>   ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();


and that may help.


Dan




> 
> Calling a simple helloworld service, I get null result while SOAP response message seems correct.
>    System.out.println(fuzzimpl.sayHello());
> 
> SayHello method Signature:
>    public String sayHello();
> 
> The SOAP response message:
> <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security S:mustUnderstand="1"><wsu:Timestamp xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>
> 
> Do you have an idea of what append and how to solve it?
> 
> Thanks and Regards,
> Julien
> 
> Global Trace:
> 
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: https://localhost:8443/FuzzWSService
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: text/xml
> Headers: {Accept=[*/*], SOAPAction=[""]}
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken wsu:Id="UsernameToken-1"><wsse:Username>test</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">d3dmAYHNdMTpnVcDraYofw==</wsse:Nonce><wsu:Created>2013-04-05T10:39:49.701Z</wsu:Created></wsse:UsernameToken></wsse:Security><Action xmlns="http://www.w3.org/2005/08/addressing">http://impl.services.fuzzws.alicante.fr/FuzzWSImplPortType/sayHello</Action><MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:c351d89f-0c92-4483-998f-c553a228000a</MessageID><To xmlns="http://www.w3.org/2005/08/addressing">https://localhost:8443/FuzzWSService</To><ReplyTo xmlns="http://www.w3.org/2005/08/addressing"><Address>http://www.w3.org/2005/08/addressing/anonymous</Address></ReplyTo></soap:Header><soap:Body><ns1:sayHello xmlns:ns1="http://impl.services.fuzzws.alicante.fr/"/></soap:Body></soap:Envelope>
> --------------------------------------
> 5 avr. 2013 12:39:49 org.apache.cxf.services.FuzzWSImpl.FuzzWSImplPort.FuzzWSImplPortType
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: text/xml;charset=UTF-8
> Headers: {content-type=[text/xml;charset=UTF-8], Server=[Jetty(8.0.1.v20110908)], transfer-encoding=[chunked]}
> Payload: <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"><S:Header><wsse:Security S:mustUnderstand="1"><wsu:Timestamp xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="_1"><wsu:Created>2013-04-05T10:39:49Z</wsu:Created><wsu:Expires>2013-04-05T10:44:49Z</wsu:Expires></wsu:Timestamp></wsse:Security></S:Header><S:Body><ns2:sayHelloResponse xmlns:ns2="http://impl.services.fuzzws.alicante.fr/"><ns2:hello>Hello</ns2:hello></ns2:sayHelloResponse></S:Body></S:Envelope>
> --------------------------------------
> null
> 
> Sample code for the client:
> 
>            ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>            factory.setServiceClass(FuzzWSImpl.class);
>            factory.setAddress("https://localhost:8443/FuzzWSService");
> 
>            FuzzWSImpl fuzzimpl = (FuzzWSImpl) factory.create();
> 
>            Client cxfClient = ClientProxy.getClient(fuzzimpl);
>            //Log SOAP message
>            cxfClient.getInInterceptors().add(new LoggingInInterceptor());
>            cxfClient.getOutInterceptors().add(new LoggingOutInterceptor());
>            //Set Http conduit
>            HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
>            TLSClientParameters param = new TLSClientParameters();
>            param.setDisableCNCheck(true);
>            http.setTlsClientParameters(param);
> 
>            //Set properties
>            Map<String, Object> outProps = new HashMap<String, Object>();
>            //Set userName token action
>            outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
>            // Set username
>            outProps.put(WSHandlerConstants.USER, "test");
>            // Password type : plain text
>            outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
>            // for hashed password use:
>            //properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
>            // Callback used to retrieve password for given user.
>            outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
>            ClientPasswordCallback.class.getName());
>            //Add nonce and created timestamp
>            outProps.put(WSHandlerConstants.ADD_UT_ELEMENTS, WSConstants.NONCE_LN + " " + WSConstants.CREATED_LN);
> 
>            //Enable web securiry
>            WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
>            cxfClient.getEndpoint().getOutInterceptors().add(wssOut);
>            //For addressing
>            cxfClient.getEndpoint().getOutInterceptors().add(new org.apache.cxf.ws.addressing.MAPAggregator());
>            cxfClient.getEndpoint().getOutInterceptors().add(new org.apache.cxf.ws.addressing.soap.MAPCodec());
> 
>            //sayHello
>            System.out.println(fuzzimpl.sayHello());
> 

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com