根文件,并且将其放在他们的com/techyatra/helloclient/jax文件夹中。若要知道细节,就查阅网上的资源。
HelloServer是一个服务端的终端接口。 HelloService是一个服务 HelloException是WSDL文档中wsdl:fault映射过来的异常类。Person类是从WSDL文件中的Person模式中生成的Java类的绑定映射文件。 这些存根将会被HelloService客户端应用程序使用,这些应用位于com.techyatra.helloclient.JAXClient 和 com.techyatra.helloclient.Client.
客户端应用程序主要的入口点就是com.techyatra.helloclient.Client类,它接受命令行的参数,有需要的话执行参数重载和检查,创建一个Person对象,最后经过JAXClient来调用这个对象。
package com.techyatra.helloclient; public class Client { public static void main(String[] args) throws Exception { ... if (args[0].equals("jax")) { com.techyatra.helloclient.jax.Person person = new com.techyatra.helloclient.jax.Person(); person.setTitle(args[1]); person.setName(args[2]); JAXClient jaxClient = new JAXClient(); jaxClient.invoke(person); } } }
package com.techyatra.helloclient; import com.techyatra.helloclient.jax.*; public class JAXClient { ... public void invoke(Person person) throws Exception { HelloService service = new HelloService(); HelloServer server = (HelloServer) service.getHelloServerPort(); String ret = server.hello(person); System.out.println(ret); } }
现在,执行Ant run命令将显示下面的信息: [java] No arguments specified. Overriding arguments to – jax Mr. Doe [java] Alive and well. Thank you and hello Mr. Doe!
但是这正是我们想要的! 尽管我们没有在这篇文章中讨论到,但是基于Axis客户端框架的代码和WSDL2Java脚本文件都可以下载到,基于Axis框架的客户段源代码在mustangwsclient/com/techyatra/hellowsclient/AxisClient.java,而且包含了命令行参数的批处理文件wsdl2javaHello.bat,能够在mustangwsclient根目录中找到。若要删除Axis引用,直接删除mustangwsclient/com/techyatra/helloclient/axis目录和mustangwsclient/com/techyatra/helloclient/AxisClient.java 源文件。
让我们回顾一下我们这里的WebService进行部署: 解开源代码包。 针对我们的服务器应用程序: 执行Ant编译任务。 执行wsgenMustang.bat批处理文件生成所需要的文件。 执行Ant run任务调用来构建MustangWS.jar文件。 我们现在可以在http://localhost:9090/HelloServer中运行HelloServer服务,而且键入http://localhost:9090/HelloServer?WSDL还能够看到动态生成的WSDL文档内容。 针对客户端应用程序: 如果对Axis没有兴趣就删除mustangwsclient/com/techyatra/helloclient/axis目录和mustangwsclient/com/techyatra/helloclient/AxisClient.java 源文件。 运行wsImportHello.bat批处理文件生成客户端存根。 运行Ant的run任务就可以了。
资源: Matrix Java&开源社区:http://www.matrix.org.cn上一页 [1 上一页 [1] [2] [3] [4] [5] [6] 下一页
|