当前位置: 首页 > 知识库问答 >
问题:

Apache CXF-不能满足任何策略备选方案

司马同
2023-03-14

我正在为https://efactura.dgi.gub.uy:6470/eprueba/ws_personagetactempresarialprueba?wsdl第三方WSDL实现一个webservice客户机。

我使用apache-cxf3.0.4wsdl2java生成java clases。

Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP);
outProps.put(WSHandlerConstants.SIGNATURE_PARTS, "");
outProps.put(WSHandlerConstants.USER, "<aliasCertName>");
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientCallbackHandler.class.getName());
outProps.put(WSHandlerConstants.SIG_PROP_FILE, "client_sign.properties");
outProps.put(WSHandlerConstants.SIGNATURE_PARTS, "{Element}{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/v1.2/ws-securitypolicy-1.2.xsd}SignedParts;{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body;");
outProps.put(WSHandlerConstants.ENCRYPTION_PARTS, "{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body");
outProps.put(WSHandlerConstants.ENC_PROP_FILE, "client_sign.properties");


/*
* Create service, port and send the request
*/
ObjectFactory objectFactory = new ObjectFactory();
WSPersonaGetActEmpresarialExecute req = objectFactory.createWSPersonaGetActEmpresarialExecute();
req.setRut("21047573001133");
WSPersonaGetActEmpresarial service = new WSPersonaGetActEmpresarial();
WSPersonaGetActEmpresarialSoapPort port = service.getWSPersonaGetActEmpresarialSoapPort();

//Obtain a reference to the CXF endpoint using the ClientProxy helper:
Client client = ClientProxy.getClient(wsPersonaGetActEmpresarialSoapPort);
client.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));


WSPersonaGetActEmpresarialExecuteResponse response = port.execute(req);
03:07:26.227 [main] WARN  o.a.c.w.p.AssertionBuilderRegistryImpl - No assertion builder for type {http://www.datapower.com/extensions}summary registered.
03:07:26.229 [main] WARN  o.a.c.w.p.AssertionBuilderRegistryImpl - No assertion builder for type {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512}SignedParts registered.
03:07:26.232 [main] DEBUG o.a.cxf.ws.policy.PolicyEngineImpl - Alternative {http://www.datapower.com/extensions}summary is not supported
03:07:26.233 [main] DEBUG o.a.cxf.ws.policy.PolicyEngineImpl - Alternative {http://www.datapower.com/extensions}summary is not supported
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:161)
    at com.sun.proxy.$Proxy33.execute(Unknown Source)
    at tests.consultaPorRUT.main(consultaPorRUT.java:150)
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:172)
    at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:146)
    at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:142)
    at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:584)
    at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:313)
    at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:294)
    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.updateClientPolicy(HTTPConduit.java:338)
    at org.apache.cxf.transport.http.HTTPConduit.getClient(HTTPConduit.java:855)
    at org.apache.cxf.transport.http.HTTPConduit.configureConduitFromEndpointInfo(HTTPConduit.java:360)
    at org.apache.cxf.transport.http.HTTPConduit.finalizeConfig(HTTPConduit.java:440)
    at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:242)
    at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:222)
    at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:229)
    at org.apache.cxf.endpoint.AbstractConduitSelector.createConduit(AbstractConduitSelector.java:145)
    at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:107)
    at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63)
    at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:849)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:509)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
    ... 2 more

我需要如何解决这个错误?

共有1个答案

晁绍辉
2023-03-14

当WSDL中有安全策略时,可以使用不同的方式配置WS-Security。您正在通过基于“操作”的方法配置WS-Security。但是,查看WSDL,该策略并不是标准的。因此,您最好保留当前的配置,但为客户机代码编写一个拦截器来断言相关的策略。

 类似资料:
  • 问题内容: 我正在尝试创建第三方WS的客户端。我的应用程序在JBoss AS 6(及其Apache CXF 2.3.1堆栈)上运行。我通过wsconsume(wsdl2java)生成了客户端代码。当我尝试连接到WS时,出现异常: WSDL的Auth部分如下所示: 客户代码: 我尝试获取导管时抛出异常: 我怀疑这是由于非标准的MS政策所致,我需要适当的Intercerptor来处理此政策,但是有人可

  • 我从wsdl中使用cxf和camel创建了一个web服务。下面是我的bean配置: 我还配置了ssl。我使用springBoot,我的属性文件是: 服务器端口=8442安全。需要ssl=true服务器。ssl。密钥存储类型=PKCS12服务器。ssl。密钥存储=类路径:密钥存储。p12服务器。ssl。密钥存储密码=123456服务器。ssl。密钥别名=testalias 服务的wsdl位于以下地址

  • 我正在尝试使用boto构建DynamoDB表,这将在表中保存IAM策略的各个方面。我已经为keyschema定义了属性,我不理解错误。我对DYanmoDB和AWS非常陌生。这是我的代码: 这就是我得到的错误: botocore.exceptions.ClientError:调用CreateTable操作时发生错误(ValidationException):检测到1个验证错误:值'[com.amaz

  • 主要内容:完全备份,累计增量备份,差异增量备份常用的备份策略有完全备份和增量备份,而增量备份有可细分为累计增量备份和差异增量备份。下面来分别讲述不同备份策略以及之间的区别。 完全备份 完全备份 是指把所有需要备份的数据全部备份。当然,完全备份可以备份整块硬盘、整个分区或某个具体的目录。对于 Linux 操作系统来说,完全备份指的就是将根目录下的所有文件进行备份。 完全备份的好处是,所有数据都进行了备份,系统中任何数据丢失都能恢复,且恢复效率较

  • 问题内容: 我有一个协议P1,它提供了Objective-C可选功能之一的默认实现。 当我提供可选功能的默认实现时,会出现警告 编译器警告: 版: 斯威夫特:3 Xcode:8(公开发行) 尝试: 尝试添加但无济于事 题: 我该如何解决? 有没有解决的办法? 码: 问题答案: 虽然我认为我可以回答您的问题,但这不是您想要的答案。 TL; DR: 功能可能当前不在协议扩展中。您可以创建一个基类,尽管

  • 描述演示策略实施特性的任务 开启限流。这个任务展示如何使用Istio来动态限制到服务的流量