繁体   English   中英

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生成的同一客户端的main方法。 以下是我的客户代码。

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();
        }

像这样更改代码后,它就可以工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM