Я пытаюсь вызвать сторонний веб-сервис .net с помощью ws-security, и я получаю следующее исключение, несмотря на настройку всех необходимых параметров в WSS4JOutInterceptor.Проблема с использованием службы WS-Security Enabled с использованием конечной точки camel cxf - Не найдено ни одного имени пользователя
org.apache.cxf.interceptor.Fault: Нет имени пользователя доступны в org.apache.cxf.ws.security.wss4j.policyhandlers.TransportBindingHandler.handleBinding (TransportBindingHandler.java:177) [CXF-RT-WS -security-3.0.2.jar: 3.0.2] at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor $ PolicyBasedWSS4JOutInterceptorInternal.handleMessageInternal (PolicyBasedWSS4JOutInterceptor.java:195) [cxf-rt-ws-security-3.0. 2.jar: 3.0.2] at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor $ PolicyBasedWSS4JOutInterceptorInternal.handleMessage (PolicyBasedWSS4JOutInterceptor.java:114) [cxf-rt-ws-security-3.0.2.jar: 3.0.2] по адресу org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutIntercepto r $ PolicyBasedWSS4JOutInterceptorInternal.handleMessage (PolicyBasedWSS4JOutInterceptor.java:101) [cxf-rt-ws-security-3.0.2.jar: 3.0.2] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept (PhaseInterceptorChain.java:307) [cxf-core-3.0.2.jar: 3.0.2] по адресу org.apache.cxf.endpoint.ClientImpl.doInvoke (ClientImpl.java:514) [cxf-core-3.0.2.jar: 3.0.2 ] at org.apache.cxf.endpoint.ClientImpl.invoke (ClientImpl.java:416) [cxf-core-3.0.2.jar: 3.0.2] at org.apache.camel.component.cxf.CxfProducer. процесс (CxfProducer.java:112) [camel-cxf-2.14.1.jar: 2.14.1] по адресу org.apache.camel.processor.SendProcessor.process (SendProcessor.java:120) [camel-core-2.14. 1.jar: 2.14.1] at org.apache.camel.management.InstrumentationProcessor.process (InstrumentationProcessor.java:72) [camel-core-2.14.1.jar: 2.14.1] на org.apache.camel.processor.RedeliveryErrorHandler.process (RedeliveryErrorHandler.java:416) [camel-core-2.14.1.jar: 2.14.1] по адресу org.apache.camel.processor.CamelInternalProcessor.process (CamelInternalProcessor .java: 191) [camel-core-2.14.1.jar: 2.14.1] at org.apache.camel.processor.Pipeline.process (Pipeline.java:118) [camel-core-2.14.1.jar : 2.14.1] на org.apache.camel.processor.Pipeline.process (Pipeline.java:80) [camel-core-2.14.1.jar: 2.14.1] на org.apache.camel.processor. CamelInternalProcessor.process (CamelInternalProcessor.java:191) [camel-core-2.14.1.jar: 2.14.1] at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange (TimerConsumer.java:166) [camel- core-2.14.1.jar: 2.14.1] на org.apache.camel.component.timer.TimerConsumer $ 1.run (TimerConsumer.java:74) [camel-core-2.14.1.jar : 2.14.1] на java.util.TimerThread.mainLoop (Timer.java:555) [: 1.8.0_25] на java.util.TimerThread.run (Timer.java:505) [: 1.8.0_25]
Ниже моя CXF конфигурация конечной точки
<cxf:cxfEndpoint id="telapoint"
address="https://mycompany.com/APIv2/MyService" wsdlURL="https://mycompany.com/APIv2/MyServices.svc?wsdl">
<cxf:inInterceptors>
<ref bean="loggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor" />
<ref bean="wss4jOutInterceptor" />
</cxf:outInterceptors>
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint</b>>
<bean id="wss4jOutInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken Timestamp" />
<entry key="passwordType" value="PasswordText" />
<entry key="user" value="xxxxxx" />
<entry key="passwordCallbackClass"
value="com.mycompany.t.UTPasswordCallback" />
<entry key="addUsernameTokenNonce" value="true" />
<entry key="addUsernameTokenCreated" value="true" />
</map>
</constructor-arg>
</bean>
Ниже верблюд Маршрут
<camelContext xmlns="http://camel.apache.org/schema/spring"
trace="false">
<route id="telaPoint_Camel_Route_with_CXF">
<from uri="timer://foo?fixedRate=true&period=10m" />
<setBody>
<constant>
<![CDATA[
<v2:OrdersGetByStatus xmlns:v2="http://mycompany.com/TelaFuel/v2">
<v2:status>Delivered</v2:status>
</v2:OrdersGetByStatus>
]]>
</constant>
</setBody>
<setHeader headerName="operationName">
<constant>OrdersGetByStatus</constant>
</setHeader>
<setHeader headerName="operationNamespace">
<constant>http://mycompany.com/TelaFuel/v2</constant>
</setHeader>
<to uri="telapoint" />
</route>
</camelContext>
Ниже приведены мои POM depedencies
<properties>
<camel-version>2.14.1</camel-version>
<log4j-version>1.2.17</log4j-version>
<jaxb-api-version>2.2.12</jaxb-api-version>
<jaxb-impl-version>2.2.11</jaxb-impl-version>
<cxf-version>3.0.2</cxf-version>
<log4j-version>1.2.17</log4j-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf-version}</version>
</dependency>
</dependencies>
(ниже приведен фрагмент кода WS-политики из WSDL)
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpToken/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SignedSupportingTokens>
<sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy/>
</sp:Wss11>
<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:MustSupportIssuedTokens/>
<sp:RequireClientEntropy/>
<sp:RequireServerEntropy/>
</wsp:Policy>
</sp:Trust10>
</wsp:All>
</wsp:ExactlyOne>
Willem Большое спасибо за ваш ответ. Как я уже сказал, я попытался изменить dataformat на CXF_MESSAGE/POJO, но я все равно продолжаю получать ошибку пользователя без имени. Есть ли что-то еще, что мне не хватает? – user1318214
Willem любые дополнительные мысли/варианты по этому вопросу? – user1318214
Вам необходимо настроить WSS4JOutInterceptor так же, как этот https://github.com/apache/camel/tree/master/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/ клиент/Client.java –