java Apache CXF3。具有可靠消息传递的0.4 Soap web服务引发异常
嗨,我已经用apache CXF 3.0.4
和spring4.0
创建了SOAP web服务
它对我来说工作正常,并且是用wsdl文件创建的。
现在我想向这个web服务添加Apache CXF
关于WS-RM
(web服务可靠消息传递)的额外功能
我尝试先添加一些代码,比如enable WS-Addressing
,然后在其中定义策略,但我没有任何方法可以做到这一点
请分享你的想法
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:wsa="http://cxf.apache.org/ws/addressing"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://schemas.xmlsoap.org/ws/2005/02/rm/policy http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
http://cxf.apache.org/ws/rm/manager http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="test" class="com.msp.webservices.impl.TestWSImpl"
scope="prototype"></bean>
<jaxws:endpoint id="testService" implementor="#test"
address="/TestService" publishedEndpointUrl="${tomcat.url}/${context.name}/TestService">
<jaxws:properties>
<entry key="mtom-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
<cxf:bus>
<cxf:features>
<wsa:addressing/>
<wsrm-mgr:reliableMessaging>
<wsrm-policy:RMAssertion>
<wsrm-policy:BaseRetransmissionInterval Milliseconds="4000"/>
<wsrm-policy:AcknowledgementInterval Milliseconds="2000"/>
</wsrm-policy:RMAssertion>
<wsrm-mgr:sourcePolicy>
<wsrm-mgr:sequenceTerminationPolicy maxLength="5"/>
</wsrm-mgr:sourcePolicy>
<wsrm-mgr:destinationPolicy acceptOffers="false">
</wsrm-mgr:destinationPolicy>
</wsrm-mgr:reliableMessaging>
</cxf:features>
</cxf:bus>
</beans>
添加到上下文文件的额外代码在tomcat上部署时失败
在启动时,尝试创建引发异常的序列
这是控制台日志
Nov 00, 2015 00:00:00 AM org.apache.cxf.ws.rm.Proxy invoke
INFO: Sending out-of-band RM protocol message {http://schemas.xmlsoap.org/ws/2005/02/rm}CreateSequence.
Nov 00, 2015 00:00:00 AM org.apache.cxf.services.SequenceAbstractService.SequenceAbstractSoapPort.SequenceAbstractPortType
INFO: Outbound Message
---------------------------
ID: 1
Encoding: UTF-8
Content-Type: application/soap+xml; action="http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence"
Headers:
Payload: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:tns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"><soap:Header><Action xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</Action><MessageID xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:uuid:6394efee-06ca-44c3-a165-38112b4f9b71</MessageID><To xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">soap.udp://239.255.255.250:3702</To></soap:Header><soap:Body><CreateSequence xmlns:ns2="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm"><AcksTo><ns2:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</ns2:Address></AcksTo><Expires>PT0S</Expires><Offer><Identifier>urn:uuid:ce23294b-3117-450a-89f2-d35d013b33d2</Identifier><Expires>PT0S</Expires></Offer></CreateSequence></soap:Body></soap:Envelope>
--------------------------------------
Nov 00, 2015 00:00:00 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://schemas.xmlsoap.org/ws/2005/02/rm}SequenceAbstractService#{http://schemas.xmlsoap.org/ws/2005/02/rm}CreateSequence has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
.
.
.
.
.
Nov 00, 2015 00:00:00 AM org.apache.cxf.ws.rm.Proxy invoke
SEVERE: Failed to send RM protocol message {http://schemas.xmlsoap.org/ws/2005/02/rm}CreateSequence.
org.apache.cxf.interceptor.Fault: Could not send Message.
.
.
.
.
在配置cxf2时,它可以正常工作。5.4版本,但我想使用cxf3。0.4
# 1 楼答案
我还没有在总线级别尝试过,但它可以在端点级别使用以下代码
你可以在我下面的名称空间中查找,以供参考