Apache CXF 导致问题
Apache CXF causing issue
我正在使用 Apache CXF wsdl2java 功能通过 Eclipse Mars 生成客户端代码。我正在使用 CXF 2.4 版。尝试执行客户端代码时出现以下异常。
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)
我正在使用由eclipse 生成的相同客户端的主要方法。下面是我的客户端代码。
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();
}
像这样更改代码后,它正在运行。
我正在使用 Apache CXF wsdl2java 功能通过 Eclipse Mars 生成客户端代码。我正在使用 CXF 2.4 版。尝试执行客户端代码时出现以下异常。
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)
我正在使用由eclipse 生成的相同客户端的主要方法。下面是我的客户端代码。
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();
}
像这样更改代码后,它正在运行。