




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
利用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 -Djava.ext.dirs=%Axis_Lib%set Axis_Servlet=http:/localhost:8090/myAxis/services/HelloWorld?wsdl%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -u %Axis_Servlet%备注:红色字体我的axis的目录,也就是刚才我解压出来的axis, 蓝色是我的webservice的访问地址,其他的不用处理,然后双击这个文件,产生以下几个文件:(1)、目录是:C:localhostmyAxisservicesHelloWorld(2)、四、 将这四个文件拷贝到你的客户端,创建客户端运行即可附录代码:服务端HelloWorld.javapackage webservice.axis.test;public class HelloWorld public String hello()return Hello +aaaaaaaaaaaaaaaaaa;客户端(通过刚才命令生成的四个文件)HelloWorld.java/* * HelloWorld.java * * This file was 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 interface HelloWorld extends java.rmi.Remote public java.lang.String hello() throws java.rmi.RemoteException;HelloWorldService.java/* * HelloWorldService.java * * This file was 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 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 getHelloWorld(.URL portAddress) throws javax.xml.rpc.ServiceException;HelloWorldServiceLocator.java/* * HelloWorldServiceLocator.java * * This file was 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 HelloWorldServiceLocator 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, space.QName sName) throws javax.xml.rpc.ServiceException super(wsdlLoc, sName); / Use to get a proxy class for HelloWorld private java.lang.String HelloWorld_address = http:/localhost:8090/myAxis/services/HelloWorld; public java.lang.String getHelloWorldAddress() return HelloWorld_address; / The WSDD service name defaults to the port 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.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 getHelloWorld(.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.axis.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 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.HelloWorldSoapBindingStub(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: + (serviceEndpointInterface = 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 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(serviceEndpointInterface); (org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; public space.QName getServiceName() return new space.QName(http:/localhost:8090/myAxis/services/HelloWorld, HelloWorldService); private java.util.HashSet ports = null; public java.util.Iterator getPorts() if (ports = null) ports = new java.util.HashSet(); ports.add(new space.QName(http:/localhost:8090/myAxis/services/HelloWorld, HelloWorld); return ports.iterator(); /* * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, java.lang.String address) 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 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 file was 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 HelloWorldSoapBindingStub extends org.apache.axis.client.Stub implements webservice.axis.test.batClient.HelloWorld private java.util.Vector cachedSerClasses = new 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 _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(hello); oper.setReturnType(new space.QName(/2001/XMLSchema, string); oper.setReturnClass(java.lang.String.class); oper.setReturnQName(new space.QName(, helloReturn); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.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 = endpointURL; 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 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.cachedPassword != 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); java.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 tryin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 责任课件内容大纲
- 2025版上海房地产买卖合同范本涵盖交易税费及支付方式说明
- 2025年房地产营销代理及品牌策划服务合同
- 2025第一部分:生物制药研发合同协议书
- 2025年智能家居产品广告创意合同示范文本
- 2025版跨境贸易借款合同带保证人及汇率风险对冲下载
- 2025年度建筑材料代购与绿色建筑认证服务合同
- 2025版外籍技术人员引进与管理合同书
- 2025年度专业摄影棚租赁服务合同
- 2025版文化娱乐融资咨询与专业居间服务协议
- 2025年有害生物防治员初级理论知识考核试题及答案
- 新版2026统编版小学道德与法治三年级上册 第4课《 科技力量大》第1课时 科技改变生活和科技改变观念 教案设计(教案)
- 学会交流与沟通课件
- 铁路监理培训考试试题及答案
- 2025全国企业员工全面质量管理知识竞赛题库附答案
- 供应链与贸易安全培训课件
- 严禁燃放烟花炮竹课件
- 宫颈息肉课件
- 焊接和切割作业的防火、防爆措施
- 人事任命书红头文件模板
- 探讨恶性肿瘤患者化疗后口腔溃疡治疗及护理的有效措施
评论
0/150
提交评论