﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-自然-文章分类-remote</title><link>http://www.blogjava.net/masen/category/54705.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 07 Feb 2015 03:55:12 GMT</lastBuildDate><pubDate>Sat, 07 Feb 2015 03:55:12 GMT</pubDate><ttl>60</ttl><item><title>使用XFire开发WebServices服务端(转)</title><link>http://www.blogjava.net/masen/articles/422806.html</link><dc:creator>Masen</dc:creator><author>Masen</author><pubDate>Sat, 07 Feb 2015 01:39:00 GMT</pubDate><guid>http://www.blogjava.net/masen/articles/422806.html</guid><wfw:comment>http://www.blogjava.net/masen/comments/422806.html</wfw:comment><comments>http://www.blogjava.net/masen/articles/422806.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/masen/comments/commentRss/422806.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/masen/services/trackbacks/422806.html</trackback:ping><description><![CDATA[<div style="margin: 5px 0px; font-stretch: normal; font-size: 20px; line-height: 30px; font-family: 'Microsoft YaHei'; background-color: #ffffff;"><h1><span style="font-family: Arial; line-height: 26px; font-size: 14px;">关于XFire的集合映射：这里使用了</span><span style="font-family: Arial; line-height: 26px; font-size: 14px; color: #9900ff;"><strong>JDK5.0提供的</strong>&nbsp;</span><span style="font-family: Arial; line-height: 26px; font-size: 14px;">新特性中的</span><span style="font-family: Arial; line-height: 26px; font-size: 14px; color: #9900ff;"><strong>泛型机制</strong>&nbsp;</span><span style="font-family: Arial; line-height: 26px; font-size: 14px;">，所以不需要</span><span style="font-family: Arial; line-height: 26px; font-size: 14px; color: blue;"><strong>&lt;InterfaceName&gt;.aegis.xml</strong>&nbsp;</span><span style="font-family: Arial; line-height: 26px; font-size: 14px;">文件</span></h1></div><div id="article_content" style="margin: 20px 0px 0px; font-stretch: normal; line-height: 26px; font-family: Arial; background-color: #ffffff;"><p style="margin: 0px; padding: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果您使用的是<span style="color: #ff6600;"><strong>JDK4</strong>&nbsp;</span>，那么就需要配置<span style="color: #ff6600;"><strong>&lt;InterfaceName&gt;.aegis.xml</strong>&nbsp;</span>文件，相关资料请找Google老师<br />交待一下我的开发环境：<span style="color: blue;"><strong>MyEclipse6.5</strong>&nbsp;</span>、<span style="color: green;"><strong>Tomcat-6.0.10</strong>&nbsp;</span>、<span style="color: #ff2693;"><strong>JDK1.5.0_08</strong>&nbsp;</span>、<span style="color: #ff6600;"><strong>XFire-1.2.6</strong>&nbsp;</span><br />如果对WebServics还不是很了解，请参阅我之前写过的一篇文章&#8212;&#8212;<a href="http://blog.csdn.net/jadyer/archive/2010/12/09/6065037.aspx" target="_blank" style="color: blue; text-decoration: none; font-size: 22px;"><strong>What is WebServices</strong>&nbsp;</a><br /><span style="color: green;"><strong>MyEclipse6.5自身便提供了对XFire的支持，所以我们可以直接创建一个Web&nbsp;Service&nbsp;Project</strong>&nbsp;</span><br />创建步骤&#8212;&#8212;略。网上有很多，希望勤快的您能够自行查阅<br />下面展示的是<span style="color: #9900ff;"><strong>WebServices服务端的全部代码</strong>&nbsp;</span>。<span style="color: red;"><strong>代码已亲测，全部通过</strong>&nbsp;</span><br /><span style="color: #ff2693;"><strong>其中包含了使用XFire处理简单对象的传递、对象的传递、List的传递</strong></span></p><p style="margin: 0px; padding: 0px;">&nbsp;</p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong>首先是web.xml文件</strong></span></p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong></strong></span></p><div bg_xhtml"="" style="width: 937.197937011719px;"><div><div style="border-left-color: #999999;"><strong><strong>[xhtml]</strong>&nbsp;<a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="view plain">view plain</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="copy">copy</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="print">print</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="?">?</a><div style="position: absolute; left: 420px; top: 729px; width: 21px; height: 11px; z-index: 99;"></div></strong></div></div><ol start="1"><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;?</span><span style="color: blue;">xml</span>&nbsp;<span style="color: red;">version</span>=<span style="color: blue;">"1.0"</span>&nbsp;<span style="color: red;">encoding</span>=<span style="color: blue;">"UTF-8"</span><span style="color: blue;">?&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;</span><span style="color: blue;">web-app</span>&nbsp;<span style="color: red;">xmlns</span>=<span style="color: blue;">"http://java.sun.com/xml/ns/javaee"</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">xmlns:xsi</span>=<span style="color: blue;">"http://www.w3.org/2001/XMLSchema-instance"</span>&nbsp;<span style="color: red;">version</span>=<span style="color: blue;">"2.5"</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">xsi:schemaLocation</span>=<span style="color: blue;">"http://java.sun.com/xml/ns/javaee&nbsp;&nbsp;&nbsp;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">servlet</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">servlet-name</span><span style="color: blue;">&gt;</span>XFireServlet<span style="color: blue;">&lt;/</span><span style="color: blue;">servlet-name</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">servlet-class</span><span style="color: blue;">&gt;</span>org.codehaus.xfire.transport.http.XFireConfigurableServlet<span style="color: blue;">&lt;/</span><span style="color: blue;">servlet-class</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;/</span><span style="color: blue;">servlet</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">servlet-mapping</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">servlet-name</span><span style="color: blue;">&gt;</span>XFireServlet<span style="color: blue;">&lt;/</span><span style="color: blue;">servlet-name</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">url-pattern</span><span style="color: blue;">&gt;</span>/services/*<span style="color: blue;">&lt;/</span><span style="color: blue;">url-pattern</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;/</span><span style="color: blue;">servlet-mapping</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;/</span><span style="color: blue;">web-app</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;XFireServlet拦截了所有关于/services/*的请求，即只在这个URI下开放WebService服务&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;所以对外系统开放的SebService的URL基本上都是【http://127.0.0.1:端口/项目/services/服务名】的形式&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;当我们将该WebService项目部署到Tomcat上之后，打开浏览器，然后输入http://127.0.0.1:8080/XFire_demo/services/XFireServer?wsdl&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;其中XFireServer是services.xml中&lt;service&gt;标签的&lt;name&gt;元素所定义的内容，而问号后面的wsdl参数表示查看该Web服务的WSDL(Web服务描述语言)文件&nbsp;--&gt;&nbsp;&nbsp;</strong></li></ol></div><p>&nbsp;</p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong>然后是services.xml文件</strong></span></p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong></strong></span></p><div bg_xhtml"="" style="width: 937.197937011719px;"><div><div style="border-left-color: #999999;"><strong><strong>[xhtml]</strong>&nbsp;<a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="view plain">view plain</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="copy">copy</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="print">print</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="?">?</a><div style="position: absolute; left: 420px; top: 1142px; width: 21px; height: 11px; z-index: 99;"></div></strong></div></div><ol start="1"><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;?</span><span style="color: blue;">xml</span>&nbsp;<span style="color: red;">version</span>=<span style="color: blue;">"1.0"</span>&nbsp;<span style="color: red;">encoding</span>=<span style="color: blue;">"UTF-8"</span><span style="color: blue;">?&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;该文件用于将我们写的一般的Java类暴露成WebService&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;This&nbsp;file&nbsp;should&nbsp;be&nbsp;placed&nbsp;in&nbsp;your&nbsp;classpath&nbsp;at&nbsp;"META-INF/xfire/services.xml"&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;这是XFire官网上说的，即services.xml文件需要保存在classpath下面的/META-INF/xfire/目录中&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;但MyEclipse却在项目中建立了一个WebService文件夹来保存services.xml文件&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&lt;!--&nbsp;其实MyEclipse已帮我们映射好了位置，它会自动将该文件存放在WEB-INF/classes/META-INF/xfire/目录下&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;</span><span style="color: blue;">beans</span>&nbsp;<span style="color: red;">xmlns</span>=<span style="color: blue;">"http://xfire.codehaus.org/config/1.0"</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;service标签和它所包含的XML内容为发布成Web服务的POJO提供完整的描述&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;&#9733;&#9733;注意&#9733;&#9733;在使用XFire与Spring2.0集成时，正常情况下，控制台会报告异常&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;&#9733;&#9733;注意&#9733;&#9733;此时把xmlns="http://xfire.codehaus.org/config/1.0"写到&lt;service&gt;标签里面，即可&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;&#9733;&#9733;注意&#9733;&#9733;&lt;beans&gt;&lt;service&nbsp;xmlns="http://xfire.codehaus.org/config/1.0"&gt;...&lt;servcie&gt;&lt;beans&gt;&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">service</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;Web服务被发布时所采用的唯一名称，即我们的WebServices服务对外提供的名字&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;该名字可以是任何的合法名字，它将会被客户端程序和其它需要调用我们的服务的组件用到&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;并且，服务准备好(比如发布到Tomcat上)以后，可以在浏览器中使用该名字来查看WSDL&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;The&nbsp;name&nbsp;element&nbsp;is&nbsp;required&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">name</span><span style="color: blue;">&gt;</span>XFireServer<span style="color: blue;">&lt;/</span><span style="color: blue;">name</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;Web服务发布时所使用的命名空间&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;The&nbsp;namespace&nbsp;element&nbsp;is&nbsp;optional&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">namespace</span><span style="color: blue;">&gt;</span>http://www.jadyer.com/XFireDemo<span style="color: blue;">&lt;/</span><span style="color: blue;">namespace</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;指定所要提供WebServices服务的Java类的名字，包括包名和类名&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;这里我们指定的是HelloService接口&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;如果我们的Java类没有实现任何接口，那么这里就可以直接指定Java类的名字&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;The&nbsp;serviceClass&nbsp;element&nbsp;is&nbsp;required&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">serviceClass</span><span style="color: blue;">&gt;</span>com.jadyer.server.HelloService<span style="color: blue;">&lt;/</span><span style="color: blue;">serviceClass</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;指定当WebServices服务被调用时，服务端用来处理请求的接口的Java实现类，包括包名和类名&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;这是一个可选元素，如果&lt;serviceClass&gt;指定的是一个接口，那么就必须在这里指定相应的实现类&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;The&nbsp;implementationClass&nbsp;element&nbsp;is&nbsp;optional&nbsp;--&gt;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;</span><span style="color: blue;">implementationClass</span><span style="color: blue;">&gt;</span>com.jadyer.server.HelloServiceImpl<span style="color: blue;">&lt;/</span><span style="color: blue;">implementationClass</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">&lt;/</span><span style="color: blue;">service</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">&lt;/</span><span style="color: blue;">beans</span><span style="color: blue;">&gt;</span>&nbsp;&nbsp;</strong></li></ol></div><p>&nbsp;</p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong>接着是暴露成Web服务的接口类</strong></span></p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong></strong></span></p><div bg_java"="" style="width: 937.197937011719px;"><div><div style="border-left-color: #999999;"><strong><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="view plain">view plain</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="copy">copy</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="print">print</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="?">?</a><div style="position: absolute; left: 412px; top: 1842px; width: 21px; height: 11px; z-index: 99;"></div></strong></div></div><ol start="1"><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">package</span>&nbsp;com.jadyer.server;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;java.util.List;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;com.jadyer.model.Person;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;com.jadyer.model.User;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>/**&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*&nbsp;暴露成web服务的接口类&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*/&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">interface</span>&nbsp;HelloService&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;String&nbsp;sayHello(String&nbsp;name);&nbsp;//简单对象的传递&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;Person&nbsp;getPerson(User&nbsp;u);&nbsp;//对象的传递&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;List&lt;Person&gt;&nbsp;getPersonList(Integer&nbsp;age,&nbsp;String&nbsp;name);&nbsp;//List的传递&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>}&nbsp;&nbsp;</strong></li></ol></div><p>&nbsp;</p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong>然后是暴露成Web服务的接口的实现类</strong></span></p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong></strong></span></p><div bg_java"="" style="width: 937.197937011719px;"><div><div style="border-left-color: #999999;"><strong><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="view plain">view plain</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="copy">copy</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="print">print</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="?">?</a><div style="position: absolute; left: 412px; top: 2147px; width: 21px; height: 11px; z-index: 99;"></div></strong></div></div><ol start="1"><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">package</span>&nbsp;com.jadyer.server;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;java.util.ArrayList;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;java.util.List;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;com.jadyer.model.Person;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">import</span>&nbsp;com.jadyer.model.User;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>/**&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*&nbsp;暴露成web服务的接口的实现类&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*&nbsp;@see&nbsp;该类必须显式或隐式的提供一个public的无参的【即默认的】构造函数&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*&nbsp;@see&nbsp;否则XFire将无法初始化该类&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*/&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;HelloServiceImpl&nbsp;<span style="color: blue;">implements</span>&nbsp;HelloService&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;//Default&nbsp;constructor&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;HelloServiceImpl(){}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;String&nbsp;sayHello(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">if</span>(<span style="color: blue;">null</span>==name){&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;<span style="color: red;">"Hello,World"</span>;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<span style="color: blue;">else</span>{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;<span style="color: red;">"Hello,"</span>&nbsp;+&nbsp;name;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;Person&nbsp;getPerson(User&nbsp;u)&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Person&nbsp;p&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;Person();&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.setAge(<span style="color: #c00000;">24</span>);&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.setName(u.getName());&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;p;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;List&lt;Person&gt;&nbsp;getPersonList(Integer&nbsp;age,&nbsp;String&nbsp;name)&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Person&nbsp;p&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;Person();&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.setAge(age);&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.setName(name);&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List&lt;Person&gt;&nbsp;list&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;ArrayList&lt;Person&gt;();&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list.add(p);&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;list;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>}&nbsp;&nbsp;</strong></li></ol></div><p>&nbsp;</p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong>最后再把两个POJO类补充上</strong></span></p><p style="margin: 0px; padding: 0px;"><span style="color: #0000ff;"><strong></strong></span></p><div bg_java"="" style="width: 937.197937011719px;"><div><div style="border-left-color: #999999;"><strong><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="view plain">view plain</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="copy">copy</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="print">print</a><a href="http://blog.csdn.net/jadyer/article/details/6082695#" title="?">?</a><div style="position: absolute; left: 412px; top: 2883px; width: 21px; height: 11px; z-index: 99;"></div></strong></div></div><ol start="1"><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">package</span>&nbsp;com.jadyer.model;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;User&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">private</span>&nbsp;String&nbsp;name;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;/*--&nbsp;getter和setter略&nbsp;--*/&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>}&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>/**&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*&nbsp;两个POJO类&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;*/&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">package</span>&nbsp;com.jadyer.model;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong><span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;Person&nbsp;{&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">private</span>&nbsp;Integer&nbsp;age;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">private</span>&nbsp;String&nbsp;name;&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; line-height: 18px; background-color: #f5fae2;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;/*--&nbsp;getter和setter略&nbsp;--*/&nbsp;&nbsp;</strong></li><li style="border-left-color: #999999; color: #555555; line-height: 18px; background-color: #f5fae2;"><strong>} &nbsp;</strong></li></ol></div><p>&nbsp;</p></div><img src ="http://www.blogjava.net/masen/aggbug/422806.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/masen/" target="_blank">Masen</a> 2015-02-07 09:39 <a href="http://www.blogjava.net/masen/articles/422806.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在XFire中创建WebService客户端的三种常用方式(转)</title><link>http://www.blogjava.net/masen/articles/422805.html</link><dc:creator>Masen</dc:creator><author>Masen</author><pubDate>Sat, 07 Feb 2015 01:37:00 GMT</pubDate><guid>http://www.blogjava.net/masen/articles/422805.html</guid><wfw:comment>http://www.blogjava.net/masen/comments/422805.html</wfw:comment><comments>http://www.blogjava.net/masen/articles/422805.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/masen/comments/commentRss/422805.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/masen/services/trackbacks/422805.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 本文所用到的WebServices服务端，取自我的上一篇文章中的例子&#8212;&#8212;使用XFire开发WebServices服务端这里并未涉及到JSR&nbsp;181&nbsp;Annotations的相关应用，具体的三种方式如下&#9312;通过WSDL地址来创建动态客户端&#9313;通过服务端提供的接口来创建客户端&#9314;使用Ant通过WSDL文件来生成客户端第一种方式：...&nbsp;&nbsp;<a href='http://www.blogjava.net/masen/articles/422805.html'>阅读全文</a><img src ="http://www.blogjava.net/masen/aggbug/422805.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/masen/" target="_blank">Masen</a> 2015-02-07 09:37 <a href="http://www.blogjava.net/masen/articles/422805.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>