renxiao2003 发表于 2011-12-21 08:44

Axis2之使用services.xml发布带包的Webservice

<DIV class=blog_content>
<P><SPAN>用</SPAN> Axis2<SPAN>实现</SPAN> Web Service<SPAN>,虽然可以将</SPAN> POJO<SPAN>类放在</SPAN> axis2\WEB-INF\pojo<SPAN>目录中直接发布成</SPAN> Web Service<SPAN>,这样做不需要进行任何配置,但这些</SPAN> POJO<SPAN>类不能在任何包中。这似乎有些不方便,为此,</SPAN> Axis2<SPAN>也允许将带包的</SPAN> POJO<SPAN>类发布成</SPAN> Web Service<SPAN>。<BR>&nbsp;&nbsp;&nbsp; 先实现一个</SPAN> POJO<SPAN>类,代码如下:<BR></SPAN></P>
<DIV style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><SPAN style="COLOR: #0000ff">package</SPAN> <SPAN style="COLOR: #000000">&nbsp;service;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">class</SPAN> <SPAN style="COLOR: #000000">&nbsp;MyService<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #000000">&nbsp;String&nbsp;getGreeting(String&nbsp;name)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">return</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">您好&nbsp;</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #000000">+</SPAN> <SPAN style="COLOR: #000000">&nbsp;name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">void</SPAN> <SPAN style="COLOR: #000000">&nbsp;update(String&nbsp;data)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">&lt;</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #000000">+</SPAN> <SPAN style="COLOR: #000000">&nbsp;data&nbsp;</SPAN> <SPAN style="COLOR: #000000">+</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">&gt;已经更新</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></SPAN></DIV>
<P style="TEXT-INDENT: 21.75pt"><SPAN>这个类有两个方法,这两个方法都需要发布成</SPAN> Web Service<SPAN>方法。这种方式和直接放在</SPAN> pojo<SPAN>目录中的</SPAN> POJO<SPAN>类不同。要想将</SPAN> MyService<SPAN>类发布成</SPAN> Web Service<SPAN>,需要一个</SPAN> services.xml<SPAN>文件,这个文件需要放在</SPAN> META-INF<SPAN>目录中,该文件的内容如下:</SPAN> </P>
<DIV style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">service&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="myService"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Web&nbsp;Service例子<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">parameter&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="ServiceClass"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;service.MyService&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">parameter</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-out"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-only"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">service</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN></DIV>
<P style="TEXT-INDENT: 21.75pt"><SPAN>其中</SPAN> &lt;service&gt;<SPAN>元素用于发布</SPAN> Web Service<SPAN>,一个</SPAN> &lt;service&gt;<SPAN>元素只能发布一个</SPAN> WebService<SPAN>类,</SPAN> name<SPAN>属性表示</SPAN> WebService<SPAN>名,如下面的</SPAN> URL<SPAN>可以获得这个</SPAN> WebService<SPAN>的</SPAN> WSDL<SPAN>内容:<BR></SPAN></P>
<P><a href="http://localhost:8080/axis2/services/myService?wsdl" target="_blank"><SPAN style="COLOR: #000000">http://localhost:8080/axis2/services/myService?wsdl</SPAN></A> </P>
<P style="TEXT-INDENT: 0.75pt; MARGIN-LEFT: 21pt"><SPAN>其中</SPAN> name<SPAN>属性名就是上面</SPAN> URL<SPAN>中</SPAN> "?"<SPAN>和</SPAN> "/"<SPAN>之间的部分。</SPAN> </P>
<P style="TEXT-INDENT: 21.75pt">&lt;description&gt;<SPAN>元素表示当前</SPAN> Web Service<SPAN>的描述,</SPAN> &lt;parameter&gt;<SPAN>元素用于设置</SPAN> WebService<SPAN>的参数,在这里用于设置</SPAN> WebService<SPAN>对应的类名。在这里最值得注意的是</SPAN> &lt;messageReceivers&gt;<SPAN>元素,该元素用于设置处理</SPAN> WebService<SPAN>方法的处理器。例如,</SPAN> getGreeting<SPAN>方法有一个返回值,因此,需要使用可处理输入输出的</SPAN> RPCMessageReceiver<SPAN>类,而</SPAN> update<SPAN>方法没有返回值,因此,需要使用只能处理输入的</SPAN> RPCInOnlyMessageReceiver<SPAN>类。</SPAN> </P>
<P style="TEXT-INDENT: 21.75pt"><SPAN>使用这种方式发布</SPAN> WebService<SPAN>,必须打包成</SPAN> .aar<SPAN>文件,</SPAN> ..aar<SPAN>文件实际上就是改变了扩展名的</SPAN> .jar<SPAN>文件。在现在建立了两个文件:</SPAN> MyService.java<SPAN>和</SPAN> services.xml<SPAN>。将</SPAN> MyService.java<SPAN>编译,生成</SPAN> MyService.class<SPAN>。</SPAN> services.xml<SPAN>和</SPAN> MyService.class<SPAN>文件的位置如下:</SPAN> </P>
<P style="TEXT-INDENT: 0.75pt; MARGIN-LEFT: 21pt"><SPAN>D:\ws\service\MyService.class</SPAN> </P>
<P style="TEXT-INDENT: 21.75pt"><SPAN>D:\ws\META-INF\services.xml<BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN>在</SPAN> windows<SPAN>控制台中进入</SPAN> ws<SPAN>目录,并输入如下的命令生成</SPAN> .aar<SPAN>文件(实际上,.jar文件也可以发布webservice,但axis2官方文档中建议使用.aar文件发布webservice):</SPAN> <SPAN><BR></SPAN></P>
<P style="TEXT-INDENT: 21.75pt"><SPAN>jar cvf ws.aar .<BR>&nbsp;&nbsp;&nbsp; </SPAN><SPAN>最后将</SPAN> ws.aar<SPAN>文件复制到</SPAN> &lt;Tomcat<SPAN>安装目录</SPAN> &gt;\webapps\axis2\WEB-INF\services<SPAN>目录中,启动</SPAN> Tomcat<SPAN>后,就可以调用这个</SPAN> WebService<SPAN>了。调用的方法和</SPAN> <A id=viewpost1_TitleUrl href="/blog/336495"><SPAN style="COLOR: #000000">《WebService大讲堂之Axis2(1):用POJO实现0配置的WebService》</SPAN></A> <SPAN>所讲的方法类似。</SPAN> </P>
<P style="TEXT-INDENT: 21.75pt"><SPAN>另外</SPAN> services.xml<SPAN>文件中也可以直接指定</SPAN> WebService<SPAN>类的方法,如可以用下面的配置代码来发布</SPAN> WebService<SPAN>:</SPAN> </P>
<DIV style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">service&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="myService"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Web&nbsp;Service例子<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">parameter&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="ServiceClass"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;service.MyService&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">parameter</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">operation&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="getGreeting"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">operation</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">operation&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="update"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">operation</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">service</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN></DIV>
<P style="TEXT-INDENT: 21.75pt"><SPAN>上面的配置代码前面的部分和以前的</SPAN> services.xml<SPAN>文件的内容相同,但后面使用了</SPAN> &lt;operation&gt;<SPAN>元素来指定每一个</SPAN> WebService<SPAN>方法,并单独指定了处理每一个方法的处理器。对于客户端来说,调用使用这两个</SPAN> services.xml<SPAN>文件发布的</SPAN> WebService<SPAN>并没有太大我区别,只是使用第二个</SPAN> services.xml<SPAN>文件发布</SPAN> WebServices<SPAN>后,在使用</SPAN> wsdl2java<SPAN>命令或使用</SPAN> C#<SPAN>、</SPAN> delphi<SPAN>等生成客户端的</SPAN> stub<SPAN>时,</SPAN> update<SPAN>方法的</SPAN> String<SPAN>类型被封装在了</SPAN> update<SPAN>类中,在传递</SPAN> update<SPAN>方法的参数时需要建立</SPAN> update<SPAN>类的对象实例。而使用第一个</SPAN> services.xml<SPAN>文件发布的</SPAN> WebService<SPAN>在生成</SPAN> stub<SPAN>时直接可以为</SPAN> update<SPAN>方法传递</SPAN> String<SPAN>类型的参数。从这一点可以看出,这两种方法生成的</SPAN> WSDL<SPAN>有一定的区别。但实际上,如果客户端程序使用第一个</SPAN> services.xml<SPAN>文件发布的</SPAN> WebService<SPAN>生成</SPAN> stub<SPAN>类时(这时</SPAN> update<SPAN>方法的参数是</SPAN> String<SPAN>),在服务端又改为第二个</SPAN> services.xml<SPAN>文件来发布</SPAN> WebService<SPAN>,这时客户端并不需要再重新生成</SPAN> stub<SPAN>类,而可以直接调用</SPAN> update<SPAN>方法。也就是说,服务端使用什么样的方式发布</SPAN> WebService<SPAN>,对客户端并没有影响。</SPAN> </P>
<P style="TEXT-INDENT: 21.75pt"><SPAN>如果想发布多个</SPAN> WebService<SPAN>,可以使用</SPAN> &lt;serviceGroup&gt;<SPAN>元素,如再建立一个</SPAN> MyService1<SPAN>类,代码如下:<BR></SPAN></P>
<DIV style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><SPAN style="COLOR: #0000ff">package</SPAN> <SPAN style="COLOR: #000000">&nbsp;service<BR></SPAN><SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">class</SPAN> <SPAN style="COLOR: #000000">&nbsp;MyService1<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #000000">&nbsp;String&nbsp;getName()&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">return</SPAN> <SPAN style="COLOR: #000000">&nbsp;</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">bill</SPAN> <SPAN style="COLOR: #000000">"</SPAN> <SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></SPAN></DIV>
<P style="TEXT-INDENT: 21.75pt"><SPAN>在</SPAN> services.xml<SPAN>文件中可以使用如下的配置代码来配置</SPAN> MyService<SPAN>和</SPAN> MyService1<SPAN>类:</SPAN> </P>
<DIV style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">serviceGroup</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp; &lt;</SPAN> <SPAN style="COLOR: #800000">service&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="myService"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; Web&nbsp;Service例子<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">parameter&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="ServiceClass"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service.MyService&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">parameter</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-out"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-only"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp; &lt;/</SPAN> <SPAN style="COLOR: #800000">service</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp; &lt;</SPAN> <SPAN style="COLOR: #800000">service&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="myService1"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; Web&nbsp;Service例子<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">description</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">parameter&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN> <SPAN style="COLOR: #0000ff">="ServiceClass"</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; service.MyService1&nbsp;&nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">parameter</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-out"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN> <SPAN style="COLOR: #800000">messageReceiver&nbsp;</SPAN> <SPAN style="COLOR: #ff0000">mep</SPAN> <SPAN style="COLOR: #0000ff">="http://www.w3.org/2004/08/wsdl/in-only"</SPAN> <SPAN style="COLOR: #ff0000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; class</SPAN> <SPAN style="COLOR: #0000ff">="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"</SPAN> <SPAN style="COLOR: #ff0000">&nbsp;</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN> <SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">messageReceivers</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&nbsp;&nbsp;&nbsp; &lt;/</SPAN> <SPAN style="COLOR: #800000">service</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN> <SPAN style="COLOR: #800000">serviceGroup</SPAN> <SPAN style="COLOR: #0000ff">&gt;</SPAN> <SPAN style="COLOR: #000000"><BR></SPAN></DIV></DIV>
页: [1]
查看完整版本: Axis2之使用services.xml发布带包的Webservice