I am using Apache CXF wsdl2java feature to generate client code using Eclipse Mars. I am using CXF version 2.4. When trying to execute the client code i am getting the below exception.
org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied.
at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:47)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at com.sun.proxy.$Proxy29.zCustomerInvoiceERPByIDorDTQueryResponseIn(Unknown Source)
at com.scmworx.xi.appl.se.ZCustomerInvoiceERPByIDorDTQueryResponseIn_BNCustomerInvoiceERPByIDorDTQueryResponseIn_Client.main(ZCustomerInvoiceERPByIDorDTQueryResponseIn_BNCustomerInvoiceERPByIDorDTQueryResponseIn_Client.java:106)
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied.
at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative(EffectivePolicyImpl.java:155)
at org.apache.cxf.ws.policy.EffectivePolicyImpl.initialise(EffectivePolicyImpl.java:88)
at org.apache.cxf.ws.policy.PolicyEngineImpl.getEffectiveClientRequestPolicy(PolicyEngineImpl.java:202)
at org.apache.cxf.ws.policy.PolicyOutInterceptor.handle(PolicyOutInterceptor.java:111)
at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:45)
... 9 more
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at com.sun.proxy.$Proxy29.zCustomerInvoiceERPByIDorDTQueryResponseIn(Unknown Source)
at com.scmworx.xi.appl.se.ZCustomerInvoiceERPByIDorDTQueryResponseIn_BNCustomerInvoiceERPByIDorDTQueryResponseIn_Client.main(ZCustomerInvoiceERPByIDorDTQueryResponseIn_BNCustomerInvoiceERPByIDorDTQueryResponseIn_Client.java:106)
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied.
at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative(EffectivePolicyImpl.java:155)
at org.apache.cxf.ws.policy.EffectivePolicyImpl.initialise(EffectivePolicyImpl.java:88)
at org.apache.cxf.ws.policy.PolicyEngineImpl.getEffectiveClientRequestPolicy(PolicyEngineImpl.java:202)
at org.apache.cxf.ws.policy.PolicyOutInterceptor.handle(PolicyOutInterceptor.java:111)
at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:45)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
I am using the same client's main method generated by eclipse. Below is my client code.
try {
SVCustomerInvoiceERPByIDorDTQueryResponseIn document = new SVCustomerInvoiceERPByIDorDTQueryResponseIn();
ZCustomerInvoiceERPByIDorDTQueryResponseIn port = document.getBNCustomerInvoiceERPByIDorDTQueryResponseInSOAP12();
Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
req_ctx.put(BindingProvider.USERNAME_PROPERTY, "user");
req_ctx.put(BindingProvider.PASSWORD_PROPERTY, "password");
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://servertm.onlinesapaccess.com:8004/sap/bc/srt/xip/sap/zzcustomerinvoiceerpbyidordtqu/800/sv_customerinvoiceerpbyidordtque/bn_customerinvoiceerpbyidordtqueryresponse_in");
ZCustomerInvoiceERPByIDorDTQueryMessageSync idQuery = new ZCustomerInvoiceERPByIDorDTQueryMessageSync();
ZCustInvcERPByIDQrySCustInvcSelByIDorDate inputs = new ZCustInvcERPByIDQrySCustInvcSelByIDorDate();
CustomerInvoiceID id = new CustomerInvoiceID();
idQuery.setCustInvcSelByIDorDate(inputs);
List<CustomerInvoiceERPByIDResponseMessageSync> invoiceDataList = port.zCustomerInvoiceERPByIDorDTQueryResponseIn(idQuery).getCustomerInvoices();
} catch (DatatypeConfigurationException ex) {
ex.printStackTrace();
} catch (StandardMessageFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ZCustomerInvoiceERPByIDorDTQueryResponseIn.class);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setAddress("http://servertm.onlinesapaccess.com:8004/sap/bc/srt/xip/sap/ zzcustomerinvoiceerpbyidordtqu/800/sv_customerinvoiceerpbyidordtque/bn_customerinvoiceerpbyidordtqueryresponse_in");
ZCustomerInvoiceERPByIDorDTQueryResponseIn port = (ZCustomerInvoiceERPByIDorDTQueryResponseIn) factory.create();
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.getAuthorization().setUserName("ECC0412");
http.getAuthorization().setPassword("Interface");
ZCustomerInvoiceERPByIDorDTQueryMessageSync idQuery = new ZCustomerInvoiceERPByIDorDTQueryMessageSync();
ZCustInvcERPByIDQrySCustInvcSelByIDorDate inputs = new ZCustInvcERPByIDQrySCustInvcSelByIDorDate();
CustomerInvoiceID id = new CustomerInvoiceID();
idQuery.setCustInvcSelByIDorDate(inputs);
List<CustomerInvoiceERPByIDResponseMessageSync> invoiceDataList = port.zCustomerInvoiceERPByIDorDTQueryResponseIn(idQuery).getCustomerInvoices();
} catch (DatatypeConfigurationException ex) {
ex.printStackTrace();
} catch (StandardMessageFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
After changing code like this it is working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.