cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Taillard <julien.taill...@alicante.fr>
Subject Problem while reading soap response
Date Fri, 05 Apr 2013 11:18:48 GMT
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());


Mime
View raw message