使用axis自动生成webservice客户端代码_第1页
使用axis自动生成webservice客户端代码_第2页
使用axis自动生成webservice客户端代码_第3页
使用axis自动生成webservice客户端代码_第4页
使用axis自动生成webservice客户端代码_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、利用AXIS生成客户端文件,使得开发webservice更加简单,以下是我的个人代码,工具:Myeclipse7.0,axis1.4,tomcat5.5,jdk1.5一、 下载axis的jar包,我的是axis-bin-1_4.zip包,解压后有axis的lib目录,一会儿我们要用,二、 在myeclip se中创建自己的webservice工程,这个在的文库里有,三、 在C盘目录下创建一个批处理文件,我的名字是wsdltojava.bat,内容如下:set Axis_Lib=E:jaraxisasixToolaxis-bin-1_4axis-1_4libset Java_Cmd=java -

2、Djava.ext.dirs=%Axis_Lib%set Axis_Servlet=%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -u %Axis_Servlet%备注:红色字体我的axis的目录,也就是刚才我解压出来的axis, 蓝色是我的webservice的访问地址,其他的不用处理,然后双击这个文件,产生以下几个文件:(1)、目录是:C:localhostmyAxisservicesHelloWorld(2)、四、 将这四个文件拷贝到你的客户端,创建客户端运行即可附录代码:服务端HelloWorld.javapackage webservice.ax

3、is.test;public class HelloWorld public String hello()return "Hello "+"aaaaaaaaaaaaaaaaaa"客户端(通过刚才命令生成的四个文件)HelloWorld.java/* * HelloWorld.java * * This auto-generated from WSDL * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */package webservice.axis.test.

4、batClient;public interface HelloWorld extends java.rmi.Remote public java.lang.String hello() throws java.rmi.RemoteException;HelloWorldService.java/* * HelloWorldService.java * * This auto-generated from WSDL * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */package webservi

5、ce.axis.test.batClient;public interface HelloWorldService extends javax.xml.rpc.Service public java.lang.String getHelloWorldAddress(); public webservice.axis.test.batClient.HelloWorld getHelloWorld() throws javax.xml.rpc.ServiceException; public webservice.axis.test.batClient.HelloWorld getHelloWor

6、ld(.URL portAddress) throws javax.xml.rpc.ServiceException;HelloWorldServiceLocator.java/* * HelloWorldServiceLocator.java * * This auto-generated from WSDL * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */package webservice.axis.test.batClient;public class HelloWorldService

7、Locator extends org.apache.axis.client.Service implements webservice.axis.test.batClient.HelloWorldService public HelloWorldServiceLocator() public HelloWorldServiceLocator(org.apache.axis.EngineConfiguration config) super(config); public HelloWorldServiceLocator(java.lang.String wsdlLoc, javax.xml.

8、namespace.QName sName) throws javax.xml.rpc.ServiceException super(wsdlLoc, sName); / Use to get a proxy class for HelloWorld private java.lang.String HelloWorld_address = "" public java.lang.String getHelloWorldAddress() return HelloWorld_address; / The WSDD service name defaults to the p

9、ort name. private java.lang.String HelloWorldWSDDServiceName = "HelloWorld" public java.lang.String getHelloWorldWSDDServiceName() return HelloWorldWSDDServiceName; public void setHelloWorldWSDDServiceName(java.lang.String name) HelloWorldWSDDServiceName = name; public webservice.axis.test

10、.batClient.HelloWorld getHelloWorld() throws javax.xml.rpc.ServiceException .URL endpoint; try endpoint = new .URL(HelloWorld_address); catch (.MalformedURLException e) throw new javax.xml.rpc.ServiceException(e); return getHelloWorld(endpoint); public webservice.axis.test.batClient.HelloWorld getHe

11、lloWorld(.URL portAddress) throws javax.xml.rpc.ServiceException try webservice.axis.test.batClient.HelloWorldSoapBindingStub _stub = new webservice.axis.test.batClient.HelloWorldSoapBindingStub(portAddress, this); _stub.setPortName(getHelloWorldWSDDServiceName(); return _stub; catch (org.apache.axi

12、s.AxisFault e) return null; public void setHelloWorldEndpointAddress(java.lang.String address) HelloWorld_address = address; /* * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote

13、getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException try if (webservice.axis.test.batClient.HelloWorld.class.isAssignableFrom(serviceEndpointInterface) webservice.axis.test.batClient.HelloWorldSoapBindingStub _stub = new webservice.axis.test.batClient.HelloWorldSoapBindingSt

14、ub(new .URL(HelloWorld_address), this); _stub.setPortName(getHelloWorldWSDDServiceName(); return _stub; catch (java.lang.Throwable t) throw new javax.xml.rpc.ServiceException(t); throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpoi

15、ntInterface = null ? "null" : serviceEndpointInterface.getName(); /* * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote getPort(space.QName portName, Class

16、 serviceEndpointInterface) throws javax.xml.rpc.ServiceException if (portName = null) return getPort(serviceEndpointInterface); java.lang.String inputPortName = portName.getLocalPart(); if ("HelloWorld".equals(inputPortName) return getHelloWorld(); else java.rmi.Remote _stub = getPort(serv

17、iceEndpointInterface); (org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; public space.QName getServiceName() return new space.QName("", "HelloWorldService"); private java.util.HashSet ports = null; public java.util.Iterator getP

18、orts() if (ports = null) ports = new java.util.HashSet(); ports.add(new space.QName("", "HelloWorld"); return ports.iterator(); /* * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, java.lang.String a

19、ddress) throws javax.xml.rpc.ServiceException if ("HelloWorld".equals(portName) setHelloWorldEndpointAddress(address); else / Unknown Port Name throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); /* * Set the endpoint address for

20、the specified port name. */ public void setEndpointAddress(space.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException setEndpointAddress(portName.getLocalPart(), address); HelloWorldSoapBindingStub.java/* * HelloWorldSoapBindingStub.java * * This auto-generat

21、ed from WSDL * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter. */package webservice.axis.test.batClient;public class HelloWorldSoapBindingStub extends org.apache.axis.client.Stub implements webservice.axis.test.batClient.HelloWorld private java.util.Vector cachedSerClasses = ne

22、w java.util.Vector(); private java.util.Vector cachedSerQNames = new java.util.Vector(); private java.util.Vector cachedSerFactories = new java.util.Vector(); private java.util.Vector cachedDeserFactories = new java.util.Vector(); static org.apache.axis.description.OperationDesc _operations; static

23、_operations = new org.apache.axis.description.OperationDesc1; _initOperationDesc1(); private static void _initOperationDesc1() org.apache.axis.description.OperationDesc oper; org.apache.axis.description.ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper.setName("h

24、ello"); oper.setReturnType(new space.QName("", "string"); oper.setReturnClass(java.lang.String.class); oper.setReturnQName(new space.QName("", "helloReturn"); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.

25、apache.axis.constants.Use.ENCODED); _operations0 = oper; public HelloWorldSoapBindingStub() throws org.apache.axis.AxisFault this(null); public HelloWorldSoapBindingStub(.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault this(service); super.cachedEndpoint = endpointUR

26、L; public HelloWorldSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault if (service = null) super.service = new org.apache.axis.client.Service(); else super.service = service; (org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); protected

27、 org.apache.axis.client.Call createCall() throws java.rmi.RemoteException try org.apache.axis.client.Call _call = super._createCall(); if (super.maintainSessionSet) _call.setMaintainSession(super.maintainSession); if (super.cachedUsername != null) _call.setUsername(super.cachedUsername); if (super.c

28、achedPassword != null) _call.setPassword(super.cachedPassword); if (super.cachedEndpoint != null) _call.setTargetEndpointAddress(super.cachedEndpoint); if (super.cachedTimeout != null) _call.setTimeout(super.cachedTimeout); if (super.cachedPortName != null) _call.setPortName(super.cachedPortName); j

29、ava.util.Enumeration keys = super.cachedProperties.keys(); while (keys.hasMoreElements() java.lang.String key = (java.lang.String) keys.nextElement(); _call.setProperty(key, super.cachedProperties.get(key); return _call; catch (java.lang.Throwable _t) throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论