1

我已经尝试了之前的消息/论坛中提到的许多选项。它们似乎都不起作用。

请在这方面帮助我。请注意,我只需要编写一个客户端,因为该服务已经由不同的供应商托管:

问题:

我在 JAVA 1.5 和 Apache CXF 2.6 上使用 jboss-4.2.3GA。(使用 ANT 作为构建工具)

我有一个需要 WssUsername Token.(PasswordText) 机制的 Web 服务。

a)我已经确定 cxf-rt-core-2.2.7.jar,cxf-ws-addr-2.2.7.jar,cxf-rt-ws-policy-2.2.7.jar,cxf-rt-ws- security-2.2.7.jar 都在类路径中。

b) 还导入了以下 XML:

<import resource="classpath:META-INF/cxf/cxf.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-policy.xml" />  
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-addr.xml" />

c) 将我的策略配置如下:

<cxf:bus>
      <cxf:features>
      <p:policies/>
         <cxf:logging/>
      </cxf:features>
      <cxf:inInterceptors>
            <ref bean="logInbound"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="logInbound"/>
        </cxf:inFaultInterceptors>  
   </cxf:bus>


  <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>


   <jaxws:client name="{namespace of the WSDL}<name attribute of the desired wsdl:port elementname   createdFromAPI="true"> 
        <jaxws:properties>
        <entry key="ws-security.username" value="myusername"/>
        <entry key="ws-security.password" value="mypassword"/>        
        </jaxws:properties>
  </jaxws:client>

我的堆栈跟踪:

org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.mymethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,513 ERROR [STDERR] Jun 20, 2012 12:14:01 PM org.apache.cxf.phase.PhaseInterceptorChain unwind 
WARNING: Exception in handleFault on interceptor org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor@cfdc01 
org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyCass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,786 ERROR [STDERR] Jun 20, 2012 12:14:01 PM org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver onMessage 
SEVERE: Error occurred during error handling, give up! 
org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,935 ERROR [[CXFServlet]] Servlet.service() for servlet CXFServlet threw exception 
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:322) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        ... 28 more 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(FirstCXF.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cx
4

1 回答 1

0

我发现问题出在 jaxws:client 中的名称空间和端口详细信息错误。

我也使用了 WSS4JOutInterceptor 而不是 ws-security 标记。

于 2012-06-22T16:40:27.587 回答