Consommation d'un service web déployé sous Axis2 en POJO
Bonjour à tous,
J'ai déployé un service web POJOService avec Axis2 sous Tomcat 6.0. Ce service comporte une opération sayHello qui retourne une String à partir d'une autre String.
Voici le code du service POJOService :
Code:
1 2 3 4 5 6 7
| package service;
public class POJOService {
public String sayHello(String name) {
return "Hello " + name + " !";
}
} |
Voici le fichier services.xml associé :
Code:
1 2 3 4 5 6
| <service name="POJOService">
<parameter name="ServiceClass">service.POJOService</parameter>
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
</operation>
</service> |
Le service POJOService est effectivement déployé et son contrat WSDL est accessible à l'URL http://localhost:8080/axis2/services/POJOService?wsdl :
Code:
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service">
<wsdl:documentation>POJOService</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="sayHello" nillable="true" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns:sayHello"/>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns:sayHelloResponse"/>
</wsdl:message>
<wsdl:portType name="POJOServicePortType">
<wsdl:operation name="sayHello">
<wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello"/>
<wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="POJOServiceSoap11Binding" type="ns:POJOServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="POJOServiceSoap12Binding" type="ns:POJOServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHello">
<soap12:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="POJOServiceHttpBinding" type="ns:POJOServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="sayHello">
<http:operation location="POJOService/sayHello"/>
<wsdl:input>
<mime:content type="text/xml" part="sayHello"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="sayHello"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="POJOService">
<wsdl:port name="POJOServiceHttpSoap11Endpoint" binding="ns:POJOServiceSoap11Binding">
<soap:address location="http://10.63.0.52:8080/axis2/services/POJOService.POJOServiceHttpSoap11Endpoint"/>
</wsdl:port>
<wsdl:port name="POJOServiceHttpSoap12Endpoint" binding="ns:POJOServiceSoap12Binding">
<soap12:address location="http://10.63.0.52:8080/axis2/services/POJOService.POJOServiceHttpSoap12Endpoint"/>
</wsdl:port>
<wsdl:port name="POJOServiceHttpEndpoint" binding="ns:POJOServiceHttpBinding">
<http:address location="http://10.63.0.52:8080/axis2/services/POJOService.POJOServiceHttpEndpoint"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
Toutefois, je ne parviens à consommer ce service ni à partie d'une URL, ni à partir d'un client Axis (invocation dynamique, utilisation du stub généré avec WSDL2Java), ni à partir d'un client Axis2 (parsing du WSDL sous Eclipse, utilisation du stub généré avec wsdl2java).
Des suggestions ?
Merci à vous.