your WSDL contains several proprietary policy assertions and CXF is complaining about those assertions.
You have two options. 1. get an equivalent WSDL without those proprietary assertions 2. use IgnorablePolicyInterceptorProvider to explicitly ignore those assertions. If you go for option 2, you can find an example in and its beans configuration file. http://svn.apache.org/repos/asf/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/IgnorablePolicyInterceptorProviderTest.java regards, aki 2013/2/13 Vishwajit Pantvaidya <[email protected]>: > Thanks for the help Dan. That moved things a little ahead. I was able to > add the interceptors - but did not know what phase string I need to have > them return. So I debugged the flow in CXF code that is throwing the error > - and it seems: > 1. the policy in the wsdl has many elements indicated as options > (wsp:Optional=true). But the code in PolicyEngineImpl.supportsAlternative > seems to be ignoring that setting - it checks only for the variable named > optional, not the wsp:Optional="true" value > 2. From the reason the error is thrown, it seems that if I provide a > supported alternative (Assertor?), the error will not get thrown I.e. > Things may work. But the forum post > http://comments.gmane.org/gmane.comp.apache.cxf.user/21774 from an earlier > user talks about defining AssertionBuilders and > PolicyInterceptorProviders. And my use case seems exactly same as that > described in this post. So do I need to define an alternative selector or > do I need AssertionBuilders / PolicyInterceptorProviders? > 3. Further, the endpoint does not really seem to be enforcing these > policies - if I edit the wsdl to remome the policies and use the edited > wsdl in my dispatch client call, everything works and I do get the data > from the svc. But when I use the wsdl with the policies, I get: > > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/webas/710/soap/features/transportbinding/}OptimizedXMLT > ransfer registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/webas/630/soap/features/session/}Session registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/webas/700/soap/features/CentralAdministration/}CentralA > dministration registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/NW05/soap/features/commit/}enableCommit registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/NW05/soap/features/blocking/}enableBlocking registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/NW05/soap/features/transaction/}required registered. > Feb 12, 2013 11:00:59 PM > org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl > handleNoRegisteredBuilder > WARNING: No assertion builder for type > {http://www.sap.com/NW05/soap/features/wsrm/}enableWSRM registered. > javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can > be satisfied. > at org.apache.cxf.jaxws.DispatchImpl.mapException(DispatchImpl.java:285) > at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:388) > at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:241) > at SoapCaller.send(SoapCaller.java:188) > at SoapCaller.send(SoapCaller.java:184) > at SAPPollerAdapter.main(SAPPollerAdapter.java:70) > Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy > alternatives can be satisfied. > at > org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolic > yImpl.java:165) > at > org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyIm > pl.java:145) > at > org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.j > ava:141) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEn > gineImpl.java:555) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImp > l.java:301) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEng > ineImpl.java:283) > at > org.apache.cxf.transport.http.policy.PolicyUtils.getClient(PolicyUtils.java > :150) > at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:308) > at > org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransport > Factory.java:248) > at > org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFa > ctory.java:229) > at > org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFa > ctory.java:236) > at > org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(Abstract > ConduitSelector.java:88) > at > org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelect > or.java:61) > at > org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:8 > 43) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:526) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:461) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:364) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317) > at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:352) > at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:381) > ... 4 more > > > FYI here is the policy part of the endpoint wsdl: > > <wsp:UsingPolicy wsdl:required="true" /> > <wsp:Policy wsu:Id="BN_BN_binding"> > <saptrnbnd:OptimizedXMLTransfer > uri="http://xml.sap.com/2006/11/esi/esp/binxml" > xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbindin > g/" > wsp:Optional="true" /> > <saptrnbnd:OptimizedMimeSerialization > > xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedm > imeserialization" > wsp:Optional="true" /> > <wsp:ExactlyOne > xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> > <wsp:All> > <sp:TransportBinding > > xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" > > xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/polic > y" > > xmlns:wsa="http://www.w3.org/2005/08/addressing" > xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" > > xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" > > xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"> > <wsp:Policy> > <sp:TransportToken> > <wsp:Policy> > > <sp:HttpsToken> > > <wsp:Policy> > > <sp:HttpBasicAuthentication /> > > </wsp:Policy> > > </sp:HttpsToken> > </wsp:Policy> > </sp:TransportToken> > <sp:AlgorithmSuite> > <wsp:Policy> > > <sp:Basic128Rsa15 /> > </wsp:Policy> > </sp:AlgorithmSuite> > <sp:Layout> > <wsp:Policy> > <sp:Strict /> > </wsp:Policy> > </sp:Layout> > </wsp:Policy> > </sp:TransportBinding> > </wsp:All> > <wsp:All> > <sp:TransportBinding > > xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" > > xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/polic > y" > > xmlns:wsa="http://www.w3.org/2005/08/addressing" > xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" > > xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" > > xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"> > <wsp:Policy> > <sp:TransportToken> > <wsp:Policy> > > <sp:HttpsToken> > > <wsp:Policy> > > <sp:RequireClientCertificate /> > > </wsp:Policy> > > </sp:HttpsToken> > </wsp:Policy> > </sp:TransportToken> > <sp:AlgorithmSuite> > <wsp:Policy> > > <sp:Basic128Rsa15 /> > </wsp:Policy> > </sp:AlgorithmSuite> > <sp:Layout> > <wsp:Policy> > <sp:Strict /> > </wsp:Policy> > </sp:Layout> > </wsp:Policy> > </sp:TransportBinding> > </wsp:All> > <wsp:All> > <sp:TransportBinding > > xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" > > xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/polic > y" > > xmlns:wsa="http://www.w3.org/2005/08/addressing" > xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" > > xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" > > xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"> > <wsp:Policy> > <sp:TransportToken> > <wsp:Policy> > > <sp:HttpsToken> > > <wsp:Policy> > > <sapsp:HTTPSSO2 /> > > </wsp:Policy> > > </sp:HttpsToken> > </wsp:Policy> > </sp:TransportToken> > <sp:AlgorithmSuite> > <wsp:Policy> > > <sp:Basic128Rsa15 /> > </wsp:Policy> > </sp:AlgorithmSuite> > <sp:Layout> > <wsp:Policy> > <sp:Strict /> > </wsp:Policy> > </sp:Layout> > </wsp:Policy> > </sp:TransportBinding> > </wsp:All> > </wsp:ExactlyOne> > <wsaw:UsingAddressing > xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" > wsp:Optional="true" /> > </wsp:Policy> > <wsp:Policy wsu:Id="IF_IF_QueryLeadIn"> > <sapsession:Session > > xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/"> > > <sapsession:enableSession>false</sapsession:enableSession> > </sapsession:Session> > <sapcentraladmin:CentralAdministration > > xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/Centra > lAdministration/" > wsp:Optional="true"> > > <sapcentraladmin:BusinessApplicationID>00163E0327EB1EE1B9A728D061073881 > </sapcentraladmin:BusinessApplicationID> > </sapcentraladmin:CentralAdministration> > </wsp:Policy> > <wsp:Policy wsu:Id="OP_IF_OP_FindByElements"> > <sapcomhnd:enableCommit > > xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</s > apcomhnd:enableCommit> > <sapblock:enableBlocking > > xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</s > apblock:enableBlocking> > <saptrhnw05:required > > xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no > </saptrhnw05:required> > <saprmnw05:enableWSRM > xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false > </saprmnw05:enableWSRM> > </wsp:Policy> > > > > Thanks, > > > Vish. > > > On 2/12/13 1:04 PM, "Daniel Kulp" <[email protected]> wrote: > >> >>The Dispatch things are not proxies and thus the ClientProxy.getClient >>call wouldn't work. >> >>I think you need to cast the Dispatch to a CXF specific DispatchImpl and >>call the getClient method on it: >> >>((org.apache.cxf.jaxws.DispatchImpl)dispatch).getClient(); >> >>Hope that helps. >> >> >>Dan >> >> >> >>On Feb 11, 2013, at 7:27 PM, vishp <[email protected]> wrote: >> >>> I am using jax-ws (cxf 2.4.3) dispatch client to invoke a webservice. >>>Since >>> the wsdl specifies some policies, my call fails with the error >>> "javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives >>>can >>> be satisfied". >>> >>> After researching the forums, it seems I need to add an interceptor to >>> handle this situation. Now all the sample code that I have seen to do >>>this >>> is like: >>> ... >>> Client client = ClientProxy.getClient(servicePort); >>> ... >>> >>> My code using the dispatch client is like: >>> >>> Service svc = Service.create(wsdlurl, serviceNs); >>> dispatch = svc.createDispatch(portName, SOAPMessage.class, >>> Service.Mode.MESSAGE); >>> Binding binding = dispatch.getBinding(); >>> List<Handler> handlerChain = binding.getHandlerChain(); >>> handlerChain.add(new SOAPLoggingHandler(logger)); >>> binding.setHandlerChain(handlerChain); >>> >>> I dont know how to get a Client object from the dispatch api so that I >>>can >>> set interceptors like: >>> cxfClient.getInInterceptors().add(...); >>> >>> I found this link in this forum which suggests it should be very easy: >>> >>>http://cxf.547215.n5.nabble.com/adding-features-and-or-interceptors-to-a- >>>dynamic-jax-ws-dispatcher-client-td3200104.html >>> But after observing the interfaces for these classes and a few others, >>>I am >>> unable to figure it out. Pls help. >>> >>> >>> >>> >>> -- >>> View this message in context: >>>http://cxf.547215.n5.nabble.com/adding-interceptors-to-a-dynamic-jax-ws-d >>>ispatcher-client-tp5723001.html >>> Sent from the cxf-user mailing list archive at Nabble.com. >> >>-- >>Daniel Kulp >>[email protected] - http://dankulp.com/blog >>Talend Community Coder - http://coders.talend.com >> >
