标签:pre sage arp return init location orm iter pack
最近开始学习了下在Myeclipse开发工具下基于WebSerivce的开发,下面将相关相关关键信息予以记录
<!-- 加载Axis2 --> <servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
<!-- HelloWorld表示您的WebService服务名 --> <service name="HelloWorld" > <!-- HelloWorld表示您的WebService服务描述 --> <description> HelloWorld Service Example </description> <!-- 这个必须是这个服务的类路径 --> <parameter name="ServiceClass"> cn.homily.action.HelloWorld </parameter> <!-- 这个是这个服务的方法名 --> <operation name="getHello"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </operation> <operation name="getWorld"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </operation> <operation name="getHelloWorld"> <!-- 这里要注意,当没有返回值时才用 org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver, 没有参数还是用RPCMessageReceiver--> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> </operation> </service>
package cn.homily.action; //服务名 public class HelloWorld {
//服务方法 public String getHello(String name) { return "Hello, " + name + "."; } //服务方法 public String getWorld(String name) { return "World," + name + "."; } //服务方法 public String getHelloWorld() { return "Hello,World"; } }
经过以上步骤,我们的WebService基本代码已经全了,现在看看实际效果。
This XML file does not appear to have any style information associated with it. The document tree is shown below. <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://action.homily.cn" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://action.homily.cn"> <wsdl:documentation>HelloWorld</wsdl:documentation> <wsdl:types>...</wsdl:types> <wsdl:message name="getHelloRequest"> <wsdl:part name="parameters" element="ns:getHello"/> </wsdl:message> <wsdl:message name="getHelloResponse"> <wsdl:part name="parameters" element="ns:getHelloResponse"/> </wsdl:message> <wsdl:message name="getHelloWorldRequest"> <wsdl:part name="parameters" element="ns:getHelloWorld"/> </wsdl:message> <wsdl:message name="getHelloWorldResponse"> <wsdl:part name="parameters" element="ns:getHelloWorldResponse"/> </wsdl:message> <wsdl:message name="getWorldRequest"> <wsdl:part name="parameters" element="ns:getWorld"/> </wsdl:message> <wsdl:message name="getWorldResponse"> <wsdl:part name="parameters" element="ns:getWorldResponse"/> </wsdl:message> <wsdl:portType name="HelloWorldPortType"> <wsdl:operation name="getHello"> <wsdl:input message="ns:getHelloRequest" wsaw:Action="urn:getHello"/> <wsdl:output message="ns:getHelloResponse" wsaw:Action="urn:getHelloResponse"/> </wsdl:operation> <wsdl:operation name="getHelloWorld"> <wsdl:input message="ns:getHelloWorldRequest" wsaw:Action="urn:getHelloWorld"/> <wsdl:output message="ns:getHelloWorldResponse" wsaw:Action="urn:getHelloWorldResponse"/> </wsdl:operation> <wsdl:operation name="getWorld"> <wsdl:input message="ns:getWorldRequest" wsaw:Action="urn:getWorld"/> <wsdl:output message="ns:getWorldResponse" wsaw:Action="urn:getWorldResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="HelloWorldSoap11Binding" type="ns:HelloWorldPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getHello"> <soap:operation soapAction="urn:getHello" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getHelloWorld"> <soap:operation soapAction="urn:getHelloWorld" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getWorld"> <soap:operation soapAction="urn:getWorld" 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="HelloWorldSoap12Binding" type="ns:HelloWorldPortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getHello"> <soap12:operation soapAction="urn:getHello" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getHelloWorld"> <soap12:operation soapAction="urn:getHelloWorld" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getWorld"> <soap12:operation soapAction="urn:getWorld" 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="HelloWorldHttpBinding" type="ns:HelloWorldPortType"> <http:binding verb="POST"/> <wsdl:operation name="getHello"> <http:operation location="getHello"/> <wsdl:input> <mime:content type="application/xml" part="parameters"/> </wsdl:input> <wsdl:output> <mime:content type="application/xml" part="parameters"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getHelloWorld"> <http:operation location="getHelloWorld"/> <wsdl:input> <mime:content type="application/xml" part="parameters"/> </wsdl:input> <wsdl:output> <mime:content type="application/xml" part="parameters"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="getWorld"> <http:operation location="getWorld"/> <wsdl:input> <mime:content type="application/xml" part="parameters"/> </wsdl:input> <wsdl:output> <mime:content type="application/xml" part="parameters"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HelloWorld"> <wsdl:port name="HelloWorldHttpSoap11Endpoint" binding="ns:HelloWorldSoap11Binding"> <soap:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpSoap11Endpoint/"/> </wsdl:port> <wsdl:port name="HelloWorldHttpSoap12Endpoint" binding="ns:HelloWorldSoap12Binding"> <soap12:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpSoap12Endpoint/"/> </wsdl:port> <wsdl:port name="HelloWorldHttpEndpoint" binding="ns:HelloWorldHttpBinding"> <http:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpEndpoint/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
基于Myeclipse+Axis2的WebService开发实录
标签:pre sage arp return init location orm iter pack
原文地址:http://www.cnblogs.com/oumi/p/6697084.html