Hi,

A typo in the post below, the variable name "greeter" in the getClient line of 
the code in 2 is actually "addrPort"


David
________________________________
From: David Wynter
Sent: 23 February 2017 14:48:58
To: users@cxf.apache.org; cohei...@apache.org
Subject: Re: Getting CXF to ignore wsdl errors


I have now tried the following and all throw the same exception:


1. Modify the wsdl adding the namespace and this  <http-conf:client 
CacheControl="no-cache" /> to the wsdl:servce element. Then used wsdl2java to 
generate the client code.

2. I added this to my code:


    EWSAddressService_Service as = new EWSAddressService_Service();
    addrPort = as.getEWSAddressServiceSoap11();

Client client = ClientProxy.getClient(greeter);
HTTPConduit http = (HTTPConduit) client.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(32000);

http.setClient(httpClientPolicy);

    Map<String, Object> addrOutProps = new HashMap<String, Object>();
    Client client = org.apache.cxf.frontend.ClientProxy.getClient(addrPort);
    Endpoint addrCxfEndpoint = client.getEndpoint();
    addrOutProps.put(WSHandlerConstants.ACTION, 
WSHandlerConstants.USERNAME_TOKEN);
    addrOutProps.put(WSHandlerConstants.USER, "CSWT01@CSWTXML2");
    addrOutProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, 
AddrPasswordCallback.class.getName());
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(addrOutProps);
    addrCxfEndpoint.getOutInterceptors().add(wssOut);
    addrCxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
    addrCxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());



3. I added this to the wsssec.xml I am loading


   <http-conf:conduit 
name="{http://services.uk.equifax.com/schema/v2}EWSAddressServiceSoap11.http-conduit";>
    <http-conf:client Connection="Keep-Alive"
                      MaxRetransmits="1"
                      AllowChunking="false" />
  </http-conf:conduit>

At this point I cannot understand why the address object is null. I cannot see 
where it defines adding the address details, they are in the wsdl and in the 
generated code?

I can see in this HttpConduit class code


    private Address setupAddress(Message message) throws URISyntaxException {
        String result = (String)message.get(Message.ENDPOINT_ADDRESS);
        String pathInfo = (String)message.get(Message.PATH_INFO);
        String queryString = (String)message.get(Message.QUERY_STRING);

That they should be set in message by now, What do I need to set these values?


David
________________________________
From: David Wynter <david.wyn...@creditswift.co.uk>
Sent: 22 February 2017 13:23:04
To: users@cxf.apache.org; cohei...@apache.org
Subject: Re: Getting CXF to ignore wsdl errors


Hi,


Ignore the exception, added this to the pom.xml


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>

Thus the dependencies were satisfied. The fact that CXF bundles the Bus related 
classes made me think it had everything I needed.


But clearly the wssec.xml is important, because I get this when I call the 
vendor's web service.


W 13:20:39:773 : main : org.apache.cxf.phase.PhaseInterceptorChain : 
Interceptor for 
{http://services.uk.equifax.com/schema/v2}EWSAddressService#{http://services.uk.equifax.com/schema/v2}listAddressByPostcode
 has thrown exception, unwinding now
java.lang.NullPointerException
at 
org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:104)
at 
org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:117)
at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:497)
at 
org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
at com.sun.proxy.$Proxy85.listAddressByPostcode(Unknown Source)

What should I have in my wssec.xml?


David



________________________________
From: David Wynter
Sent: 22 February 2017 13:10:01
To: users@cxf.apache.org; cohei...@apache.org
Subject: Re: Getting CXF to ignore wsdl errors


Hi Colm,


I read http://cxf.apache.org/docs/ws-security.html and 
http://cxf.apache.org/docs/ws-securitypolicy.html and used the wssecurity ut 
example. But it leaves me with a few questions not answered by the 
documentation nor the example.


The service client does not start with this exception:


Exception in thread "main" java.lang.NoClassDefFoundError: 
org/springframework/beans/BeansException
at 
uk.co.creditswift.equifaxaddress.EquifaxAddrServiceTest.directAddressTest(EquifaxAddrServiceTest.java:85)
at 
uk.co.creditswift.equifaxaddress.EquifaxAddrServiceTest.main(EquifaxAddrServiceTest.java:47)
Caused by: java.lang.ClassNotFoundException: 
org.springframework.beans.BeansException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

I saw this was an issue in V 2 CXF, so not sure why I get it now. My pom.xml 
contains cxf-rt-frontend-jaxws, cxf-rt-transports-http, cxf-rt-ws-security and 
cxf-rt-ws-policy, do I need more?


There are a few unanswered question I did not find in the documentation. I am 
not familiar with Spring, so that might be a problem.


Here are my questions:



There is no WSAddress section in the ws Policy section in my original email, so 
not sure the wsssec.xml file is used?

If it is then in the wssec.xml file this line


    <http:conduit 
name="{http://cxf.apache.org/hello_world_soap_http}GreeterPort.http-conduit";>

I guessed that the name is the endpoint, and the GreeterPort is the service 
port, but not sure what the http-conduit extension is?

Thx,


David

________________________________
From: Colm O hEigeartaigh <cohei...@apache.org>
Sent: 21 February 2017 15:39:59
To: users@cxf.apache.org
Subject: Re: Getting CXF to ignore wsdl errors

The policy expects that a UsernameToken is going to be added to the
request. For this it needs a username and password (via a CallbackHandler)
to actually construct the UsernameToken. So you have to supply these via
configuration options. Here is some spring configuration that shows how
this is done for the WS-Security system tests:

https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=systests/ws-security-examples/src/test/resources/org/apache/cxf/systest/wssec/examples/ut/client.xml;h=19b54889c88de11070a099e6f816bf307c50a094;hb=HEAD

Colm.

On Tue, Feb 21, 2017 at 3:11 PM, David Wynter <
david.wyn...@creditswift.co.uk> wrote:

> I have seen this error raised on stackoverflow and added the interceptors
> that should solve the issue, but I still get:
>
>
> W 14:59:54:169 : main : org.apache.cxf.phase.PhaseInterceptorChain :
> Interceptor for {http://services.uk.equifax.com/schema/v2}
> EWSAddressService#{http://services.uk.equifax.com/schema/v2}
> listAddressByPostcode has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: No username available
>     at org.apache.cxf.ws.security.wss4j.policyhandlers.
> TransportBindingHandler.handleBinding(TransportBindingHandler.java:171)
>     at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$
> PolicyBasedWSS4JOutInterceptorInternal.handleMessageInternal(
> PolicyBasedWSS4JOutInterceptor.java:184)
>     at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$
> PolicyBasedWSS4JOutInterceptorInternal.handleMessage(
> PolicyBasedWSS4JOutInterceptor.java:109)
>
>
> Here is the relevant part of the test code
>
>
>         EWSAddressService_Service as = new EWSAddressService_Service();
>         addrPort = as.getEWSAddressServiceSoap11();
>         Map<String, Object> addrOutProps = new HashMap<String, Object>();
>         Client client = org.apache.cxf.frontend.ClientProxy.getClient(
> addrPort);
>         Endpoint addrCxfEndpoint = client.getEndpoint();
>         addrOutProps.put(WSHandlerConstants.ACTION,
> WSHandlerConstants.USERNAME_TOKEN);
>         addrOutProps.put(WSHandlerConstants.USER, "CSWT01@CSWTXML2");
>         //addrOutProps.put(WSHandlerConstants.PASSWORD_TYPE,
> WSConstants.PW_DIGEST);
>         addrOutProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
> AddrPasswordCallback.class.getName());
>         WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(
> addrOutProps);
>         addrCxfEndpoint.getOutInterceptors().add(wssOut);
>         addrCxfEndpoint.getInInterceptors().add(new
> LoggingInInterceptor());
>         addrCxfEndpoint.getOutInterceptors().add(new
> LoggingOutInterceptor());
>
>
>
> Here is the relevant part of the wsdl
>
>   <wsp1:Policy sch0:Id="EWSAddressServiceSoap11Policy">
>     <wsp1:ExactlyOne>
>       <wsp1:All>
>         <sp1:TransportBinding>
>           <wsp1:Policy>
>             <sp1:TransportToken>
>               <wsp1:Policy>
>                 <sp1:HttpsToken RequireClientCertificate="false"/>
>               </wsp1:Policy>
>             </sp1:TransportToken>
>             <sp1:Layout>
>               <wsp1:Policy>
>                 <sp1:Lax/>
>               </wsp1:Policy>
>             </sp1:Layout>
>             <!--sp1:IncludeTimestamp/-->
>           </wsp1:Policy>
>         </sp1:TransportBinding>
>         <sp1:SupportingTokens>
>           <wsp1:Policy>
>             <sp1:UsernameToken sp1:IncludeToken="http://docs.
> oasis-open.org/ws-sx/ws-securitypolicy/200702/
> IncludeToken/AlwaysToRecipient">
>               <wsp1:Policy>
>                 <sp1:WssUsernameToken10/>
>               </wsp1:Policy>
>             </sp1:UsernameToken>
>           </wsp1:Policy>
>         </sp1:SupportingTokens>
>         <sp1:Wss10/>
>       </wsp1:All>
>     </wsp1:ExactlyOne>
>   </wsp1:Policy>
>
> What am  missing?
>
> I did try Metro for this, recommended by the supplier, but Metro has
> serious problems, loads an incorrect class, raised on their mailing list in
> 2014 and never answered. Long live CXF!
>
>
>
>
> David
>



--
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Reply via email to