Bonjour,

J'ai utilisé JAX-WS RI et WSIT pour déployer sur un serveur d'applications GlassFish v2 un service web HelloWSRM avec WS-ReliableMessaging.

Voici le contrat WSDL de ce service :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.4-hudson-208-. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.4-hudson-208-. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service/" name="HelloWSRMService">
    <ns1:Policy xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy" wsu:Id="HelloWSRMPortBindingPolicy">
        <ns1:ExactlyOne>
            <ns1:All>
                <ns2:RMAssertion xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm/policy" />
                <ns3:Ordered xmlns:ns3="http://sun.com/2006/03/rm" />
                <ns4:UsingAddressing xmlns:ns4="http://www.w3.org/2006/05/addressing/wsdl" />
            </ns1:All>
        </ns1:ExactlyOne>
    </ns1:Policy>
 
    <types>
        <xsd:schema>
            <xsd:import namespace="http://service/" schemaLocation="http://localhost:8080/HelloWSIT/HelloWSRMService?xsd=1" />
        </xsd:schema>
    </types>
 
    <message name="sayHello">
        <part name="parameters" element="tns:sayHello" />
    </message>
 
    <message name="sayHelloResponse">
        <part name="parameters" element="tns:sayHelloResponse" />
    </message>
 
    <portType name="HelloWSRM">
        <operation name="sayHello">
            <input message="tns:sayHello" />
            <output message="tns:sayHelloResponse" />
        </operation>
    </portType>
 
    <binding name="HelloWSRMPortBinding" type="tns:HelloWSRM">
        <ns5:PolicyReference xmlns:ns5="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#HelloWSRMPortBindingPolicy" />
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <operation name="sayHello">
            <soap:operation soapAction="" />
            <input>
                <soap:body use="literal" />
            </input>
            <output>
                <soap:body use="literal" />
            </output>
        </operation>
    </binding>
 
    <service name="HelloWSRMService">
        <port name="HelloWSRMPort" binding="tns:HelloWSRMPortBinding">
            <soap:address location="http://localhost:8080/HelloWSIT/HelloWSRMService" />
        </port>
    </service>
</definitions>
Lorsque je teste le service HelloWSRM avec la console d'administration de GlassFish à l'URL http://localhost:8080/HelloWSIT/HelloWSRMService?tester, le header relatif à WS-Addressing et WS-ReliableMessaging est bien inséré dans la requête SOAP :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/HelloWSIT/HelloWSRMService</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://service/HelloWSRM/sayHelloRequest</Action>
        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:e7cac55e-c69c-4769-9950-850c60e0b00b</MessageID>
        <ns3:Sequence xmlns:ns2="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:ns4="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns6="http://schemas.microsoft.com/ws/2006/05/rm">
            <ns3:Identifier>uuid:8732c10a-fdf4-459e-8a5a-b1b07fe88ca3</ns3:Identifier>
            <ns3:MessageNumber>1</ns3:MessageNumber>
        </ns3:Sequence>
        <ns3:SequenceAcknowledgement xmlns:ns2="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:ns4="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns6="http://schemas.microsoft.com/ws/2006/05/rm">
            <ns3:Identifier>uuid:24377d2a-a3a7-42cf-a719-da1d31f92205</ns3:Identifier>
            <ns3:AcknowledgementRange Lower="0" Upper="0"/>
        </ns3:SequenceAcknowledgement>
    </S:Header>
    <S:Body>
        <ns2:sayHello xmlns:ns2="http://service/">
            <name>Christophe</name>
        </ns2:sayHello>
    </S:Body>
</S:Envelope>
De même, tout se passe bien lorsque je crée une servlet cliente.

Par contre, si j'utilise une application Java en tant que client, aucun header n'est inséré dans la requête SOAP et l'exception suivant est levée :
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: A required header representing a Message Addressing Property is not present
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:187)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:254)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:224)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:117)
at $Proxy29.sayHello(Unknown Source)
at hellowsrmclient.Main.main(Main.java:12)
Voici la réponse SOAP dans ce cas :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <FaultDetail xmlns="http://www.w3.org/2005/08/addressing">
            <ProblemHeaderQName>{http://www.w3.org/2005/08/addressing}Action</ProblemHeaderQName>
        </FaultDetail>
    </S:Header>
    <S:Body>
        <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            <faultcode
                xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://www.w3.org/2005/08/addressing">ns0:MessageAddressingHeaderRequired</faultcode>
            <faultstring>A required header representing a Message Addressing Property is not present</faultstring>
        </SOAP-ENV:Fault>
    </S:Body>
</S:Envelope>
Voici le code de la servlet :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    @WebServiceRef(wsdlLocation = "http://localhost:8080/HelloWSIT/HelloWSRMService?WSDL")
    private HelloWSRMService service;
 
    protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
 
        try {
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet HelloWSRMServlet</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet HelloWSRMServlet at " + request.getContextPath() + "</h1>");
 
            service.HelloWSRM port = service.getHelloWSRMPort();
            ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:4040/HelloWSIT/HelloWSRMService");
            String name = "Christophe";
            String message = port.sayHello(name);
            out.println(message);
            out.println("</body>");
            out.println("</html>");
        } finally {
            out.close();
        }
    }
Voici le code du main de l'application :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
        service.HelloWSRMService service = new service.HelloWSRMService();
        service.HelloWSRM port = service.getHelloWSRMPort();
        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:4040/HelloWSIT/HelloWSRMService");
        String name = "Christophe";
        String message = port.sayHello(name);
 
        System.out.println(message);
 
        ((Closeable)port).close();
Si vous savez comment faire en sorte que l'application Java puisse correctement consommer le servce web avec WS-ReliableMessaging, je suis preneur...

Merci à vous.

NB : J'ai également utilisé JAX-WS RI (avec NetBeans) pour générer le client à partir du contrat WSDL du service.