首先要做的事情:
配置:
应用context.xml中
<!-- Import for camel config and beans -->
<import resource="./cxf-beans-testws.xml" />
<import resource="./camel-testws.xml" />
驼testws.xml
<!-- CAMEL CONTEXT -->
<camelContext id="camelContextTest" xmlns="http://camel.apache.org/schema/spring">
<!-- CAMEL ROUTE -->
<route id="TestWSRoute">
<description>
Camel route for testws
</description>
<from uri="cxf:bean:serviceTestProvider" />
<log message="Process" loggingLevel="DEBUG" />
<to uri="cxf:bean:serviceTestClient" />
</route>
</camelContext>
cxf-beans-testws.xml(只是相关部分)
<bean id="wss4JOutInterceptorRea" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Encrypt Signature"/>
<entry key="useSingleCertificate" value="true" />
<entry key="user" value="xxxx" />
<entry key="signaturePropRefId" value="signaturePropertiesBean" />
<entry key="signaturePropertiesBean" value-ref="signaturePropertiesTest" />
<entry key="signatureUser" value="${test.signature.certificate.alias}" />
<entry key="passwordCallbackRef" value-ref="clientCallbackTest" />
<entry key="signatureAlgorithm" value="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<entry key="signatureKeyIdentifier" value="DirectReference" />
<entry key="signatureParts" value="{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body" />
<entry key="encryptionUser" value="${test.encryption.certificate.alias}" />
<entry key="encryptionPropRefId" value="encryptionPropertiesBean" />
<entry key="encryptionPropertiesBean" value-ref="encryptionPropertiesTest" />
</map>
</constructor-arg>
</bean>
当我调用公开的Web服务(serviceTestProvider)时,SOAP消息进入,出现日志并放置WSS配置。然后将消息发送到endPoint ...并始终返回:
HTTP response '403: Forbidden' when communicating with http://...
如果我删除了wss4jOutInterceptor,那么响应就是没有wss安全性(预期的响应)。
但是,如果我将日志级别设置为DEBUG,请在所有拦截器链处理后从日志中获取Outbound消息,并从REST控制台或SoapUI手动发送...然后工作正常,没有403.所以看来这个消息形成得很好。这两个电话都是在同一台计算机上进行的,没有代理或类似的。
2016-06-17 08:59:12 INFO WSTestCXFService:234 - Outbound Message
---------------------------
ID: 4
Address: http://correct-ws-url
Http-Method: POST
Content-Type: text/xml;charset=UTF-8
Headers: {Accept=[text/xml;charset=UTF-8], accept-encoding=[gzip,deflate], breadcrumbId=[ID-MACHINENAME-55387-1466145154908-1-4], Cache-Control=[No-Cache], Connection=[Keep-Alive], host=[correct-host], SOAPAction=[method], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1">...</wsse:Security></SOAP-ENV:Header><soap:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-5"><xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="ED-4" Type="http://www.w3.org/2001/04/xmlenc#Content">...</xenc:EncryptedData></soap:Body></soap:Envelope>
没有https,只是http端点。尝试使用管道添加标头只是为了匹配REST控制台或SoapUI原始消息而没有运气。有什么猜测吗?
答案 0 :(得分:0)
最后,这是一个Windows /网络问题。几天后(2-3),根本没有变化......它开始工作了。