Apache CXF3.0.4 Soap веб-сервис с надежным исключением сообщений Messaging

Привет, я создал SOAP веб-сервис с apache CXF 3.0.4 а также spring4.0 и он работает нормально для меня и создан с помощью файла WSDL. Теперь я хочу добавить дополнительную функцию Apache CXF около WS-RM (веб-сервис надежного обмена сообщениями) к этому веб-сервису.

Я пытаюсь добавить код, например, включить 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 ответ

Решение

Я не пробовал на уровне шины, но он будет работать на уровне конечной точки с кодом ниже,

    <wsp:Policy wsu:Id="RM" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
        <wsrm:AcknowledgementInterval Milliseconds="2000" />
    </wsrm:RMAssertion>
    <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata">
        <wsam:NonAnonymousResponses />
    </wsam:Addressing>
   </wsp:Policy>


<jaxws:endpoint id="Service" implementor="#Serv" address="/TrcAndGrnWebservice" publishedEndpointUrl="${tomcat.url}/${context.name}/service">
    <jaxws:features>
        <cxf:logging/>
        <p:policies>
            <wsp:PolicyReference URI="#RM" />
        </p:policies>
    </jaxws:features>
</jaxws:endpoint>

Вы можете мое пространство имен ниже для вашей справки

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context" xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:p="http://cxf.apache.org/policy" 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:wsp="http://www.w3.org/2006/07/ws-policy"
xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util      http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.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/policy                            http://cxf.apache.org/schemas/policy.xsd
             http://cxf.apache.org/core http://cxf.apache.org/schemas/core.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.w3.org/2006/07/ws-policy http://www.w3.org/2006/07/ws-policy.xsd         
xsi:schemaLocation=http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">

<!-- Apache CXF Configuration for Webservices -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
Другие вопросы по тегам