User:Lindenb/Notebook/UMR915/20101018: Difference between revisions
From OpenWetWare
Line 131: | Line 131: | ||
jar cvf apache-tomcat-6.0.26/webapps/axis2/WEB-INF/services/myaxisservice.aar -C myaxisservice . | jar cvf apache-tomcat-6.0.26/webapps/axis2/WEB-INF/services/myaxisservice.aar -C myaxisservice . | ||
rm -rf myaxisservice | rm -rf myaxisservice | ||
==testing== | |||
ok check at | ok check at | ||
Line 141: | Line 141: | ||
<ns:return>512</ns:return> | <ns:return>512</ns:return> | ||
</ns:getTwiceResponse> | </ns:getTwiceResponse> | ||
http://localhost:8080/axis2/services/HelloAxisService/getTwice?value=XXX | |||
<soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> | |||
<soapenv:Text xml:lang="en-US">For input string: "XXX"</soapenv:Text> | |||
</soapenv:Reason> |
Latest revision as of 02:44, 18 October 2010
axis2
download from http://apache.crihan.fr/dist//ws/axis2/1_5_1/axis2-1.5.1-bin.zip
cd axis2-1.5.1/webapp ant mv axis2-1.5.1/dist/axis2.war /srv/apache-tomcat-6.0.26/webapps/
- check: http://localhost:8080/axis2/ : OK
export AXIS2_HOME=${HOME}/package/axis2-1.5.1
generating wsdl
the source:
public class HelloAxis { public int getTwice(int value) { return value*2; } }
command:
axis2-1.5.1/bin/java2wsdl.sh -cp ~/workspace/SANDBOX/bin -cn HelloAxis -of helloAxis.wsdl
<?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://ws.apache.org/axis2" 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://ws.apache.org/axis2"> <wsdl:types> <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2"> <xs:element name="getTwice"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="value" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getTwiceResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="getTwiceRequest"> <wsdl:part name="parameters" element="ns:getTwice"/> </wsdl:message> <wsdl:message name="getTwiceResponse"> <wsdl:part name="parameters" element="ns:getTwiceResponse"/> </wsdl:message> <wsdl:portType name="HelloAxisPortType"> <wsdl:operation name="getTwice"> <wsdl:input message="ns:getTwiceRequest" wsaw:Action="urn:getTwice"/> <wsdl:output message="ns:getTwiceResponse" wsaw:Action="urn:getTwiceResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HelloAxisSoap11Binding" type="ns:HelloAxisPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getTwice"> <soap:operation soapAction="urn:getTwice" 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="HelloAxisSoap12Binding" type="ns:HelloAxisPortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getTwice"> <soap12:operation soapAction="urn:getTwice" 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="HelloAxisHttpBinding" type="ns:HelloAxisPortType"> <http:binding verb="POST"/> <wsdl:operation name="getTwice"> <http:operation location="HelloAxis/getTwice"/> <wsdl:input> <mime:content type="text/xml" part="getTwice"/> </wsdl:input> <wsdl:output> <mime:content type="text/xml" part="getTwice"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HelloAxis"> <wsdl:port name="HelloAxisHttpSoap11Endpoint" binding="ns:HelloAxisSoap11Binding"> <soap:address location="http://localhost:8080/axis2/services/HelloAxis"/> </wsdl:port> <wsdl:port name="HelloAxisHttpSoap12Endpoint" binding="ns:HelloAxisSoap12Binding"> <soap12:address location="http://localhost:8080/axis2/services/HelloAxis"/> </wsdl:port> <wsdl:port name="HelloAxisHttpEndpoint" binding="ns:HelloAxisHttpBinding"> <http:address location="http://localhost:8080/axis2/services/HelloAxis"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
generating service
services.xml:
<service name="HelloAxisService"> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </messageReceivers> <parameter name="ServiceClass">HelloAxis</parameter> </service>
all: rm -rf myaxisservice mkdir myaxisservice mkdir myaxisservice/META-INF cp services.xml myaxisservice/META-INF cp bin/HelloAxis.class myaxisservice jar cvf apache-tomcat-6.0.26/webapps/axis2/WEB-INF/services/myaxisservice.aar -C myaxisservice . rm -rf myaxisservice
testing
ok check at
- http://localhost:8080/axis2/services/listServices
- http://localhost:8080/axis2/services/HelloAxisService?wsdl
- http://localhost:8080/axis2/services/HelloAxisService/getTwice?value=256
<ns:getTwiceResponse xmlns:ns="http://ws.apache.org/axis2"> <ns:return>512</ns:return> </ns:getTwiceResponse>
http://localhost:8080/axis2/services/HelloAxisService/getTwice?value=XXX
<soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Text xml:lang="en-US">For input string: "XXX"</soapenv:Text> </soapenv:Reason>