0

如何将默认 WS 寻址添加到 xml?

    <cxf:cxfEndpoint id="endpoint" xmlns:s="http://tempuri.org/"
      address="https://uslugaterytws1test.stat.gov.pl/TerytWs1.svc" 
      endpointName="s:custom" 
      serviceName="s:TerytWs1" 
      wsdlURL="classpath:/wsdl/terytws1.wsdl">
    <cxf:properties>
      <entry key="schema-validation-enabled" value="false" />
    </cxf:properties>
    <cxf:inInterceptors>
    </cxf:inInterceptors>
    <cxf:inFaultInterceptors>
    </cxf:inFaultInterceptors>
    <cxf:outInterceptors>
    </cxf:outInterceptors>
    <cxf:outFaultInterceptors>
    </cxf:outFaultInterceptors>
  </cxf:cxfEndpoint>


  <cxf:cxfEndpoint id="poxyEndpoint" xmlns:s="http://tempuri.org/"
      address="http:localhost:5678/myproxy" 
      endpointName="s:customProxy" 
      serviceName="s:TerytWs1Proxy" 
      wsdlURL="classpath:/wsdl/terytws1Proxy.wsdl">
    <cxf:properties>
      <entry key="schema-validation-enabled" value="false" />
    </cxf:properties>
    <cxf:inInterceptors>
    </cxf:inInterceptors>
    <cxf:inFaultInterceptors>
    </cxf:inFaultInterceptors>
    <cxf:outInterceptors>
      <ref component-id="wssOutInterceptor" />
    </cxf:outInterceptors>
    <cxf:outFaultInterceptors>
      <ref component-id="wssOutInterceptor" />
    </cxf:outFaultInterceptors>
  </cxf:cxfEndpoint>



  <camelContext id="proxyTerytContext" xmlns="http://camel.apache.org/schema/blueprint">
  <route id="route-TerytWs1">
      <from id="inbound" uri="cxf:bean:proxyEndpoint?dataFormat=CXF_MESSAGE" />
      <to id="outbound" uri="cxf:bean:endpoint?dataFormat=CXF_MESSAGE" />
    </route>
  </camelContext>

当我发送请求时,http:localhost:5678/myproxy我得到:

<faultcode xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</faultcode>
<faultstring xml:lang="en-US">An error occurred when verifying security for the message.</faultstring>

我已经阅读了许多类似的问题和示例,但还没有找到纯 cxf xml 的解决方案。我一直试图解决这个问题 2 天。现在我在哭。


编辑:这是一个原始的 wsdl:https
://uslugaterytws1test.stat.gov.pl/terytws1.svc?wsdl 这是我的代理:https ://github.com/woblak/training/blob/master/teryt_testProxy .wsdl
用户:TestPubliczny
通行证:1234abcd

4

1 回答 1

0

Camel 单元测试中有一些示例在启用 WS-Addressing 的情况下测试 CXF 端点;WSAddressingTest-context.xml似乎与您的问题有关?

在这里,已通过在 CXF 端点上添加wsa:addressing元素来启用 WS-Addressing features

<cxf:cxfEndpoint...>
    <cxf:features>
        <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing" />
    </cxf:features>
</cxf:cxfEndpoint>

该错误似乎与安全性有关。您配置了一个拦截器 ( wssOutInterceptor) 但没有源代码。也许您应该查看那里,看看您是否正在设置身份验证详细信息。

我还将添加消息日志记录,以便您可以查看发送到目标的有效负载内容并验证它是否包含您的凭据。

或者,如果您使用 Camel CXF 命名空间 ( xmlns:cxf="http://camel.apache.org/schema/cxf"),您可以使用:

<cxf:cxfEndpoint ... loggingFeatureEnabled="true">
  ...
</cxf:cxfEndpoint>
于 2020-04-17T08:15:28.303 回答