`

webservice开发指南

阅读更多
    http://www.360doc.com/content/11/0711/16/16915_132909866.shtml
   
2       目的和范围
这是一篇关于webservcie相关知识的介绍,其中主要包括:使用axis来进行开发和测试、axis和spring集成开发、aixs和web服务期集成开发、通过ObjectWeb Lomboz工具生成客户端和服务器代码方式等等。
核心内容包括: axis命令级别的详细解释、axis和spring相互结合开发指南、开发步骤的梳理和解释。本文只提到了Axis2的基本概念,详细知识,可以参见Axis2的相关文档。
这是重量级别的文章,对webservice知识点和axis的使用命令涉及到比较多。
2.1    主要内容包括
1、 关于webservice的基本概念
2、 Axis相关概念和命令。
3、 开发和测试工具,代码实例。
4、 开发客户端和服务器端的开发流程。
5、 开发的详细的命令介绍。
6、 如何测试的方法。
7、 发布的步骤。
8、 日志跟踪机制。
9、 其他优秀文章。
10、             相关参考资料的介绍。
11、             其他文档的发布路线图。
2.2    本文的特色
1、 有助于理解webservice深层的设计思想。 因为没有使用eclipse插件,强迫你每次可以看axis相关的知识,必然对相关的概念、代码的架构设计,可以对自动生成的代码的命名、调用细节,有比较深的理解,例如:Proxy模式的设计。
2、 增强你对工程的管理能力。 当生成代码时,你将每次手工的设置wsdl文件名称、路径名称等等,处处在影响这你。Ant是管理java的强大的工具,应用最广泛。无论多牛的开发图形工具,它的后台,对工程的管理,很多都是采用ant命令调用。
3、 提高你的测试能力。 在附件中的工程,生成的代码支持Junit测试的java代码。通过测试,当你在你应用中调用时,通过copy、paste就可以搞定。
4、 增强你的思考能力。 有些知识,网上是找不到的,这恰恰是你的机会,同时也是公司的机会,因为公司是单个人组成的。通过思考,通过动手,才能突破一些难点。例如:hibernate的Callback代码设计、强大的Template方法、多线程下数据同步和持久化、不同Ip之上数据表的操作访问,程序管理表和物理管理表的设计模式。网上,没人告诉你。不详细的它的源代码调用和相关规范,很难搞清楚。
5、 详细和大量的代码实例。 这样可以方便你引用,这些所有的代码和build.xml文件,都是经过测试和应用过的。
2.3    关于实例工程
考虑到,容量比较大,可能要自己到网站下载。参见:相关资源。
3       Web Service基本概念
3.1    基本组成
由两部分组成
·SOAP--Web Service之间的基本通信协议。
·WSDL--Web Service描述语言,它定义了Web Service做什么,怎么做和查询的信息。
The Web Service Description Language is a specification authored by IBM and Microsoft, and supported by many other organizations. WSDL serves to describe Web Services in a structured way. A WSDL description of a service tells us, in a machine-understandable way, the interface to the service, the data types it uses, and where the service is located.
Handler
A reusable class which is responsible for processing a MessageContext in some custom way. The Axis engine invokes a series of Handlers whenever a request comes in from a client or a transport listener.
SOAP
The Simple Object Access Protocol (yes, despite the fact that it sometimes doesn't seem so simple, and doesn't have anything to do with objects...). You can read the SOAP 1.1 specification at http://www.w3.org/TR/SOAP . The W3C is currently in the midst of work on SOAP 1.2, under the auspices of the XML Protocol Group .
Provider
A provider is the "back-end" Handler which is responsible for actually performing the "meat" of the desired SOAP operation. Typically this means calling a method on some back-end service object. The two commonly used providers are RPCProvider and MsgProvider, both in the org.apache.axis.providers.java package.
3.2    什么是 Webservice?
Web 是使应用程序可以以与平台和编程语言无关的方式进行相互通信的一项技术。Web 服务是一个软件接口,它描述了一组可以在网络上通过标准化的 XML 消息传递访问的操作。它使用基于 XML 语言的协议来描述要执行的操作或者要与另一个 Web 服务交换的数据。一组以这种方式交互的 Web 服务在面向服务的体系结构(Service-Oriented Architecture,SOA)中定义了特殊的 Web 服务应用程序。
3.3    什么是SOAP?
SOAP(Simple Object Access Protocol )简单对象访问协议是在分散或分布式的环境中交换信息并执行远程过程调用的轻量级协议,是一个基于XML的协议。使用SOAP,不用考虑任何特定的传输协议(最常用的还是HTTP协议),可以允许任何类型的对象或代码,在任何平台上,以任何一种语言相互通信。
SOAP包括四个部分:SOAP封装 (envelop),封装定义了一个描述消息中的内容是什么,是谁发送的,谁应当接受并处理它以及如何处理它们的框架;SOAP编码规则(encoding rules),用于表示应用程序需要使用的数据类型的实例;SOAP RPC表示(RPC representation),表示远程过程调用和应答的协定;SOAP绑定(binding),使用底层协议交换信息。
应用中比较关注的是envelop,由一个或多个Header和一个Body组成。
SOAP 在可互操作的基础 Web 服务协议栈中的位置。
3.4    什么是WSDL?
WSDL(Web Service Description Language)Web服务器描述语言是用XML文档来描述Web服务的标准,是Web服务的接口定义语言,由Ariba、Intel、IBM、MS等共同提出,通过WSDL,可描述Web服务的三个基本属性:
·服务做些什么——服务所提供的操作(方法)
·如何访问服务——和服务交互的数据格式以及必要协议
·服务位于何处——协议相关的地址,如URL
WSDL文档以端口集合的形式来描述Web服务,WSDL 服务描述包含对一组操作和消息的一个抽象定义,绑定到这些操作和消息的一个具体协议,和这个绑定的一个网络端点规范。
WSDL 在Web 服务概念性协议栈中的位置。
WSDL描述语言一般包含三部分
l         What部分:包括了type、message和portType元素
Type:定义了Web Service使用的数据结构(使用XML Schema定义)
Message:一个Message是SOAP的基本通信元素。每个Message可以有一个或多个Part,每个Part代表一个参数。
PortType:消息汇总为不同的操作并归入到一个被称为 portType的实体中。一个portType代表一个接口(Web Service支持的操作集合),每个Web Service可以有多个接口,它们都使用portType表示。每个操作又包含了input和 output部分。
l         How部分:包含binding元素
binding元素将portType绑定到特定的通信协议上(如HTTP上的SOAP协议)
l         Where部分:由service元素组成
它将portType,binding以及Web Service实际的位置(URI)放在一起描述
3.5    什么是WSDD?
WSDD就是WEB服务分布描述(Web Service Deployment Descriptor), 它定义了WEB服务的接口,如服务名、提供的方法、方法的参数等信息。
3.6    什么是UDDI?
UDDI就是统一描述、发现和集成(Universal Description, Discovery, and Integration)。UDDI用于集中存放和查找WSDL描述文件,起着目录服务器的作用。
Web 服务中的角色、操作和构件。
服务提供者。从企业的角度看,这是服务的所有者。从体系结构的角度看,这是托管访问服务的平台。
服务请求者。从企业的角度看,这是要求满足特定功能的企业。从体系结构的角度看,这是寻找并调用服务,或启动与服务的交互的应用程序。服务请求者角色可以由浏览器来担当,由人或无用户界面的程序(例如,另外一个 Web 服务)来控制它。
服务注册中心。
这是可搜索的服务描述注册中心,服务提供者在此发布他们的服务描述。在静态绑定开发或动态绑定执行期间,服务请求者查找服务并获得服务的绑定信息(在服务描述中)。对于静态绑定的服务请求者,服务注册中心是体系结构中的可选角色,因为服务提供者可以把描述直接发送给服务请求者。同样,服务请求者可以从服务注册中心以外的其它来源得到服务描述,例如本地文件、FTP 站点、Web 站点、广告和服务发现(Advertisement and Discovery of Services,ADS)或发现 Web 服务(Discovery of Web Services,DISCO)。
3.7    客户端和服务器端
3.7.1            客户端
根据wsdl文件生成的一组相关的客户端类。然后,通过wsdl地址可以访问其他系统或应用所提供的功能。
通常Web Service可以有三种类型的客户
l         商业伙伴(Business Partner)--包括分发商,零售商以及大型消费者)
此类客户通过SOAP、WSDL、ebXML、UDDI等XML技术与Web Service连接
l         瘦客户--包括Web浏览器、PDA以及无线设备
该类客户通常经由轻量协议(如HTTP)与Web Service连接
l         肥客户--包括Applet、各类应用以及现存系统
通常使用重量级协议(如IIOP)连接Web Service
3.7.2            服务器端
也就是对外提供的一个接口(本质上就是:方法),让其他不同的系统或应用可以来进行访问,本系统的功能。它包括的内容:
1. 一个对外接口
2. 该接口的实现类
3. 一个部署描述文件,描述这个服务(接口)。部署文件中的服务的信息,是可以通过axis的命令来生成的。
这些文件都是将包含在一个完整的web应用中的,当启动web容器的时候,就可以其他系统进行访问了。
4       Axis概念、命令和方法
4.1    什么是axis?
Apache Axis 是Apache WebService项目中的子项目,其最初起源于IBM的"SOAP4J",应该属于最早的一批用于构造基于SOAP应用的Framework。目前Apache Axis已经发展到了第三代,其核心是一个SOAP处理器,用于开发包括客户端,服务器端,SOAP Gateway等各种应用。事实上Apache Axis在了1.0版后,其发行版本还包括了完整的J2EE服务器插件, WSDL支持和生成,TCP/IP监视器等组件,从这个意义上来说Apahce Axis已不仅仅是个SOAP框架了,它包含了除了UDDI外对整个Web Service协议栈(Protocol Stack)的支持。
Axis本质上就是一个SOAP引擎(Apache Axis is an implementation of the SOAP),提供创建服务器端、客户端和网关SOAP操作的基本框架。但Axis并不完全是一个SOAP引擎,它还包括:
是一个独立的SOAP服务器。
是一个嵌入Servlet引擎(例如Tomcat)的服务器。
支持WSDL。
提供转化WSDL为Java类的工具。
提供例子程序。
提供TCP/IP数据包监视工具。
4.2    什么时Axis2?
A new architecture for Axis was introduced during the August 2004 Summit in Colombo, Sri Lanka. The new architecture on which Axis2 is based on is more flexible, efficient and configurable in comparison to Axis1.x architecture . Some well established concepts from Axis 1.x, like handlers etc., have been preserved in the new architecture.
Apache Axis2 not only supports SOAP 1.1 and SOAP 1.2, but it also has integrated support for the widely popular REST style of Web services . The same business logic implementation can offer both a WS-* style interface as well as a REST style interface simultaneously.
Apache Axis2 is more efficient, more modular and more XML-oriented than the older version. It is carefully designed to support the easy addition of plug-in "modules" that extend their functionality for features such as security and reliability. The Modules currently available or under development include:

    WS-ReliableMessaging - Supported by Apache Sandesha2
    WS-Coordination and WS-AtomicTransaction - Supported by Apache Kandula2
    WS-Security - Supported by Apache Rampart
    WS-Addressing -Module included as part of Axis2 core

Apache Axis2 is built on Apache AXIOM , a new high performant, pull-based XML object model.
Axis2 comes with many new features, enhancements and industry specification implementations. The key features offered are as follows:
·         Speed - Axis2 uses its own object model and StAX (Streaming API for XML) parsing to achieve significantly greater speed than earlier versions of Apache Axis.
·         Low memory foot print - Axis2 was designed ground-up keeping low memory foot print in mind.
·         AXIOM - Axis2 comes with its own light-weight object model, AXIOM, for message processing which is extensible, highly performant and is developer convenient.
·         Hot Deployment - Axis2 is equipped with the capability of deploying Web services and handlers while the system is up and running. In other words, new services can be added to the system without having to shut down the server. Simply drop the required Web service archive into the services directory in the repository, and the deployment model will automatically deploy the service and make it available for use.
·         Asynchronous Web services - Axis2 now supports asynchronous Web services and asynchronous Web services invocation using non-blocking clients and transports.
·         MEP Support - Axis2 now comes handy with the flexibility to support Message Exchange Patterns (MEPs) with in-built support for basic MEPs defined in WSDL 2.0.
·         Flexibility - The Axis2 architecture gives the developer complete freedom to insert extensions into the engine for custom header processing, system management, and anything else you can imagine .
·         Stability - Axis2 defines a set of published interfaces which change relatively slowly compared to the rest of Axis.
·         Component-oriented Deployment - You can easily define reusable networks of Handlers to implement common patterns of processing for your applications, or to distribute to partners.
·         Transport Framework - We have a clean and simple abstraction for integrating and using Transports (i.e., senders and listeners for SOAP over various protocols such as SMTP, FTP, message-oriented middleware, etc), and the core of the engine is completely transport-independent.
·         WSDL support - Axis2 supports the Web Service Description Language, version 1.1 and 2.0 , which allows you to easily build stubs to access remote services, and also to automatically export machine-readable descriptions of your deployed services from Axis2.
·         Add-ons - Several Web services specifications have been incorporated including WSS4J for security (Apache Rampart), Sandesha for reliable messaging, Kandula which is an encapsulation of WS-Coordination, WS-AtomicTransaction and WS-BusinessActivity.
·         Composition and Extensibility - Modules and phases improve support for composability and extensibility. Modules support composability and can also support new WS-* specifications in a simple and clean manner. They are however not hot deployable as they change the overall behavior of the system.
4.3    文件格式介绍
1.    JWS (Java Web Service) Files - Instant Deployment 它是格式正确的 java 文件,文件的后缀是 .jws 。如果发布,可以直接把它放到发布的工程根目录下。它不能指定包名。如果引用其他类,只能其他类也不能指定包名。
4.4    Axis工具简单操作命令和基本概念
1. 显示帮助信息:java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java
生成客户端代码实例:前提是必须的在dos切换到axis的lib目录。 然后执行这个命令。j java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -a -H -d -s -t -S true -p com.qnuse.zj114.webservice http://134.96.71.58/QnInterface/HzGsyj.asmx?wsdl
2. WSDL2Java工具用于从WSDL文件生成客户端存根(stub)代码,服务端框架(skeleton)代码以及WSDL中的数据类型文件(生成与之对应的Java代码)。
3. server-config.wsdd记录了axis已发布的Web服务的描述信息。
4.5    Axis工具wsdl2java命令参数解释
1.    -N, --NStoPkg <argument>=<value>
mapping of namespace to package
2.    -a, --all
generate code for all elements, even unreferenced ones
3.    -p, --package <argument>
         override all namespace to package mappings, use this package
          name instead
4.    -h, --help
         print this message and exit
5.     -v, --verbose
         print informational messages
6.    -t, --testCase
        为 web service 发行 junit 测试用例类
4.6    server-config.wsdd文件解释
它是AXIS的配置文件,所有发布的服务都会在里面描述。
如果还没有server-config.wsdd文件,可以先写一个发布描述文件,然后用axis来生成,以后需要发布新的服务,直接往里面添加即可。
比如有一个HelloWorld.class类,里面有sayHello(String msg)方法,想把它发布webservices,先写发布文件deploy.wsdd文件,即SOAP服务发布描述文件deploy.wsdd
http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java ">
然后,进入dos窗口,执行下列命令:
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd 即可生成server-config.wsdd文件。
如果想发布新的服务,也可以直接往server-config.wsdd里面添加service描述。
4.7    查看发布的webservice
1.首先要查看工程的web.xml的配置情况,例如:zj114boss的web.xml中对axis的配置是:
    < servlet >
       < servlet-name > axis </ servlet-name >      < servlet-class > org.apache.axis.transport.http.AxisServlet </ servlet-class >
       < load-on-startup > 5 </ load-on-startup >
    </ servlet >
    < servlet-mapping >
       < servlet-name > axis </ servlet-name >
       < url-pattern > /webservice/* </ url-pattern >
    </ servlet-mapping >
2.启动容器,或看测试环境。在IE上键入:http://134.96.71.27:8080/zj114boss-1.0/webservice 你将看到全部发布的service。
3.看详细的wsdl内容。例如:查看生产环境http://134.96.71.73/usboss/webservice/ssoService?wsdl
4.8    序列化与反序列化
序列化/反序列化器在英文中的对应翻译是Serializer/Deserializer,一个序列化器的功能是遵循一定的映射规则和编码风格,将一种类型的JAVA对象通过某种特定的机制,转换成为XML描述的形式;反序列化器的功能是序列化器所做工作的逆操作,两者相辅相成,成对出现。Axis中的序列化/反序列化器采用设计范式中的工厂模式,每一个Serializer唯一对应一个SerializerFactory;每一个Deserializer唯一对应一个 DeserializerFactory。
Axis已经为开发者提供了丰富的序列化/反序列化器,对于java的基本数据类型,绝大部分常用的容器类(比如数组类型,Vector类型等)都提供了实现,特别是提供了对W3C的DOM对象(比如Document, Element等)和符合Bean规范的JAVA对象提供了功能完善的序列化/反序列化器,但对于一些特殊类型的对象,需要通过Web服务进行传递,我们不得不开发自己的序列化/反序列化器。
4.9    Axis相比Soap v2的优点
Axis是第三代Apache SOAP的实现,从2000年起,SOAP v2开发小组开始讨论如何让Axis更加灵活、可配置,以及能够处理SOAP和来自W3C的各种XML标准。通过不断地讨论和代码编写,Axis目前相比SOAP V2取得了如下成果:
速度提高。 Axis通过基于事件的SAX对XML文档进行处理,从而在速度和效率上比Apache SOAP有所提高。
灵活性提高。
稳定性提高。
提供面向组件的部署。
提供一个简洁的传输抽象框架。其核心引擎完全于传输方式独立。从而使基于何种协议传输的选择更加灵活。
支持WSDL。包括WSDL和客户端代码生成等。
4.10       性能
axis使用1.3版,xfire使用1.0版。xfire使用spring的 servicesbean方式发布web服务。web services客户端使用delphi 7开发,分别对通过axis发布的web services及通过xfire发布的web services进行1万次连续调用(即一次获取wsdl后连续使用)。axis调用1万次内存占用48M,用时1分40秒 xfire调用1万次内存占用38M,用时1分05秒。使用axis2测试时发现通过axis2发布的web services 在delphi中可以导入,但是运行时会报错。
4.11       更多
1.参见:(文章)AXIS 详细介绍 和其他部分。
5       开发和测试工具
5.1    开发工具
1.      采用axis的相关eclipse插件、或者其他形式的插件。例如:ObjectWeb Lomboz An Eclipse based IDE for J2EE Development
2.      采用axis代码本身工具(dos命令行或ant脚本)来开发。
5.2    测试webservice接口工具
1.      vb脚本来测试。这种方式操作比较方便。
微软公司的Soap Toolkit 开发工具包,这个工具包可以从微软公司的主页:http://download.microsoft.com/download/xml/soap/2.0/W98NT42KMe/EN-US/SoapToolkit20.exe
2. 生成的*testCase.java文件来进行测试。
详细测试代码,参见测试webservice 用例代码 。
6       采用eclipse插件开发
通过这个ObjectWeb Lomboz工具来实现代码开发。这个是最简单的方式。效率非常高,但是对webservice一些基础知识的理解帮助不大。步骤如下:
1. 建一个新的工程。
2. 把wsdl文件放到工程中。
3. 点击右键,新建一个webservice客户端或服务器端代码。可以选择axis、proxy两种方式来实现。
7       采用Axis和Spring进行开发
7.1    基本流程
7.1.1            简单的Web Service实现
包含四个基本步骤:
·创建Web Service的商业逻辑(通常是一些Java类)
·将这些Java类部署到一个SOAP服务器上
·生成客户访问代码
·部署客户应用
注意: WSDL等文件的生成通常是利用厂商提供的工具来完成
7.1.2            在Axis下进行开发
This is a sample of the axis!
To run the bidbuy sample, you must do the following:
1. Set up your CLASSPATH.
2. Start a server.
3. Deploy the service.
4. Run the sample.

1. Set up your CLASSPATH. (May don’t set it, )
    The CLASSPATH must contain: an XML parser (ie., Xerces), JUnit
    (www.junit.org), all the jars in the lib directory, and the directory
    containing the samples subdirectory.
2. Start a server.
    To run the sample, you will first need to run a server. To run a very
    simple server you could run, in a separate window:
        java org.apache.axis.transport.http.SimpleAxisServer -p 8080

        java -Djava.ext.dirs=lib org.apache.axis.transport.http.SimpleAxisServer -p 8080
      
3. Deploy the service.
    To deploy the service, run:
        java org.apache.axis.client.AdminClient deploy.wsdd
      
        java -Djava.ext.dirs=lib org.apache.axis.client.AdminClient samples/bidbuy/deploy.wsdd

4. Run the sample.
    Finally, to run the client, run:
        java samples.bidbuy.TestClient
      
        java -Djava.ext.dirs=lib samples.bidbuy.TestClient
7.2    Axis与Spring的结合
Axis与spring结合,需要提供一些额外工作,即将实现web服务接口的Bean与web服务部署中服务类如何关联。如下:
<service name="GameService" type="" provider="Handler" style="rpc">
<parameter name="handlerClass" value="/blog/com.workingmouse.webservice.axis.SpringBeanRPCProvider"/>
<parameter name="springBean" value="gameInfoService"/>
<parameter name="springBeanClass" value="/blog/com.gamebase.kernel.service.GameService"/>
<parameter name="scope" value="Request"/>
<parameter name="allowedMethods" value="*"/>
.......
</service>
参数handlerClass的值是处理Bean与wsdd文件中服务类的关联。
参数springBean的值表示实现接口GameService注册的Bean的名字。
参数springBeanClass的值表示接口GameService的类。
7.3    Webservice代码设计准备
7.3.1            版本选择
根据你的工程的特点,来选择合适的axis版本。
如果在工程中采用是axis1.2版本的jar文件,如果生成服务器端和客户端时,必须采用合适的axis1.2版本的wsdl2java工具去生成代码。否则,有的不能调用。
7.3.2            软件下载
http://apache.justdn.org/ws/axis2/tools/1_0/Axis2_Code_Generator.zip
http://apache.justdn.org/ws/axis2/tools/1_0/Axis2_Service_Archiver.zip
7.3.3            War文件部署
1. 在下载的axis1.4中的本身在webapps下面本身就有一个axis目录(axis目录本身就是一个war文件解压后的一些文件,然后resin就可以配置web-id指向这个文件,当然也是可以把这war文件,放到resin的webapps目录下,然后启动servlet容器resin就可以了) 。也可以在网站上单独的下载war文件。
2. 然后可以http://localhost:8080/axis/ 来访问,
3. 点击Validation - Validate the local installation's configuration来检查配置是否运行正常。
7.3.4            好的包名命名规则
可以在根目录下建两个源文件目录:
l         Component/src/webserviceserver
l         Component/src/webserviceclient
源文件可以命名为:
com.qnuse.zj114boss.webserviceclient.huawei.SMSCardService
7.4    Webservie客户端开发
7.4.1            开发步骤
7.4.1.1             获得wsdl文件或wsdl url地址。
7.4.1.1.1       如果本身作为客户端,必须得到对方的对外提供的wsdl地址或wsdl文件。
7.4.1.1.2       如果本身作为服务器端,发布webservcie。获得wsdl文件的方式
7.4.1.1.2.1  方式一:
第一步:在spring工程中的server_config.wsdd 中, 配置要发布的函数 。 增加如下:
实例一:业务受理平台接口配置。
    < service name = "business" provider = "java:RPC" >
       < operation name = "doService"  returnQName = "businessReturn" returnType = "xsd:string" xmlns:xsd = "http://www.w3.org/2001/XMLSchema" >
           < parameter name = "wsname" type = "xsd:string" />
           < parameter name = "param" type = "xsd:string" />
       </ operation >
       < parameter name = "wsdlTargetNamespace" value = "http://www.channelsoft.com/webservice/business" />
       < parameter name = "allowedMethods" value = "*" />
       < parameter name = "className" value = "com.channelsoft.usboss.webservice.business.server.BusinessWebService" />
    </ service >
实例二: 单点登陆权限认证的配置方式。
< service name = "author" provider = "java:RPC" >
       < operation name = "login" returnQName = "loginReturn" returnType = "xsd:string" xmlns:xsd = "http://www.w3.org/2001/XMLSchema" >
           < parameter name = "userId" type = "xsd:string" />
           < parameter name = "userPwd" type = "xsd:string" />
       </ operation >
< parameter name = "wsdlTargetNamespace" value = "http://www.channelsoft.com/webservice/author" />
       < parameter name = "allowedMethods" value = "*" />
       < parameter name = "className" value = "com.channelsoft.usboss.webservice.authorization.server.AuthorImp" />
    </ service >
第二步: 启动 resin 。 可以采用本机启动resin。或在其他机器上
第三步: 在 ie 录入地址。
http://localhost:8080(端口号) /usboss ( 项目名称 )/webservice (在 web.xml 中配置的那个映射文件) /business?wsdl
就会产生那个 wsdl 文件了。 。

7.4.1.1.2.2  或通过axis提供的命令,写一个接口类,然后生成wsdl文件。参见:生成 Web服务的服务端和客户端代码
a)      同时也可通过vb脚本来测试一下,看看是否能用。参见:Webservice测试
7.4.1.2              生成客户端代码
7.4.1.2.1       不同的生成方式

Dos基本命令方式
Dos批处理命令方式
Eclipse ant方式


7.4.1.2.2        对不同的几种方式详细解释
1. 方式一:通过一定命令操作来进行生成客户端。 参数描述:参见客户端命令。
a)      在dos切换到axis工程的lib目录。
b)      实例1:java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -a -H -d -s -t -S true -p com.qnuse.zj114.webservice http://134.96.71.58/QnInterface/HzGsyj.asmx?wsdl
c)      实例2:执行:java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -s -d Session -Nurn:AddressFetcher2=com.qnuse.usboss.huawei.SMSCardService AddressBook.wsdl
解释:
                   i.              AddressFetcher2 是targetNamespace="urn:AddressFetcher2",有的wsdl文件中没有urn:则可以采用c)的实现方式
                ii.              –p 可以指定自己期望的包名,详细参见命令参数列表。
d)      实例3:Java -Djava.ext.dirs=lib -a –t -H -p com.qnuse.zj114boss.webserviceclient.huawei.SMSCardService org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/Hello.jws?wsdl ( 也可以是一个wsdl文件名称)
2. 方式二:通过脚本文件来生成。它将更快速。在axis的目录下,建一个dat或cmd后缀的文件, 例如:axis-1_4.dat(axis-1_4.cmd)在这个文件中,文件内容:java -Djava.ext.dirs=lib -a –s -H -p com.qnuse.zj114boss.webserviceclient.huawei.SMSCardService org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/Hello.jws?wsdl
这样你可以,每次仅需要修改这个文件wsdl地址或文件名,然后双击即可。
添加-s服务端的代码也将生成。-S true Seketon类也将生成。
3.  (推荐方式)方式三:建立一个单独的新工程。可以复用axis-1_4工程。
1.  在网站下载的zip形式的axis-1_4,解压后文件导入eclipse。
2.  新建一个源文件 (source folder),例如:devsrc。
3.  配置工程属性。把devsrc设置到build path,输出路径为:axis-1_4/webapps/axis/WEB-INF/classes,同时别忘了导入所有的jar文件。目的是: 利用eclipse的编译功能,同时方便resin和tomcat来配置web-id。
4.  导入和配置相关文件。把build.xml文件放到devsrc下面,同时也要把将要生成的wsdl文件放到devsrc下面。
5.  配置build.xml文件。在<target wsdl2java> 设置:文件名称、package名称 、namespace 其他相关参数一般不用配置。公共参数 我都已经配置好了。如果想问为什么?请看:axis的帮助文档中的ant task的设置。
6.  然后可以运行<target wsdl2java>。生成了你所有一直盼望出现的文件。
7.  最后,你就可以在相关的文件中进行修改了。每一个文件的使用。详细参见:(文章)AXIS 详细介绍
7.4.1.3              最终将在指定的包名下生成不同文件
根据生成命令参数不同,生成的文件数量也不同。当生成全部文件时,例如:


No.

文件

用途
1.

deploy.wsdd

MyService 服务的部署描述文件
2.

MyService.java

MyService 服务的接口文件,客户端和服务器端都需要
3.

MyServiceService.java

获得 MyService 服务的接口文件
4.

MyServiceServiceLocator.java

实现 MyServiceService 接口
5.

MyServiceSoapBindingImpl.java

实现 MyService 接口,服务器需 要其中补充业务逻辑
6.

MyServiceSoapBindingSkeleton.java

MyService 服务的服务端框 架代码 , 实现 MyService, org.apache.axis.wsdl.Skeleton 接口
7.

MyServiceSoapBindingStub.java

MyService 服务的客户端存根代码 , 实现 MyService 接口
8.

undeploy.wsdd

注销 MyService 服务的部署描述文件

7.4.1.4              在应用程序中通过代理类调用接口
详细参见,自动生成文件*testCase.java的调用方式。Java代码测试
Note:没有必要设计独立的proxy类,自动生成的代码*Locator本身就是一个proxy类。
7.4.2            其他注意事项
1. 可以把dos命令存为.dat格式的文件。然后直接双击就可以完成。这样每次仅仅修改这个文件即可。.cmd格式的文件是Windows NT/2000的批处理文件,其实与BAT文件功能相同,只是为了与DOS/Windows 9x下的BAT有所区别。
2. 只要在web.xml中配置了axis的servlet,当启动web服务器时,例如:然后在浏览器中,输入:http://10.130.24.169:8080/zjusboss/webservice/SysUserSynProcessor?wsdl
a)      10.130.24.169:8080/zjusboss 发布的地址和端口号和web-id(应用标识)
如果本机启动就是localhost:8080/zjusboss
b)      webservice是在web.xml<servlet>中配置的。<url-pattern>/webservice/*</url-pattern>。 * 代表了不同的对外的服务名称(也就是对外的接口)。
3. 根据不同的需要来设定不同的操作命令的参数,可以通过运行:java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java 看到详细的帮助。更多的指导参见:axis的指导文档。
7.4.3            生成客户端和服务器端命令详细实例
如果在dos环境下,首先导航到axis的目录。
7.4.3.1             帮助命令
java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java
7.4.3.2             生成客户端代码命令
java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -a -H -t -p com.qnuse.zj114.webservice http://134.96.71.142/QnInterface/SendMsgService.asmx?WSDL
7.4.3.3             生成全部代码命令
java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -a -H -d -s -t -S true -p com.qnuse.zj114.webservice http://134.96.71.58/QnInterface/HzGsyj.asmx?wsdl
7.5    Webservice服务器端开发
关于生成wsdl方式,可以参照:获得wsdl 文件或wsdl url 地址。
可以采用不同的方式进行开发。
7.5.1            在Axis发布的工程中直接开发
详细参见:代码工程(它和这个文档一起发布) 。它是在axis1.4工程之上来开发的。
7.5.2            可以单独建立一个工程来开发
可以仿照axis发布的zip文件结构。
1. 把相关jar导入。
2. 采用合适的文件夹结构。
3. 在eclipse中和resin(tomcat)服务器中,进行合理的配置。
7.5.3            在Spring框架下开发
1. 写一个对外接口(即方法)。可以参见SysUserSynProcessorImp的开发。
2. 该接口的实现类。写一个继承ServletEndpointSupport的类。onInit方法内,拿到getWebApplicationContext相关的dao或其他处理service。让dao或service来完成实际的操作。
3. 一个部署描述文件,描述这个服务(接口),在server-config.wsdd文件中,手工加入相关的服务信息。它也可以通过axis的部署命令来生成的。
4. 访问实例:http://134.96.71.27:7070/usboss/webservice/SysUserSynProcessor?wsdl(webservice是在web.xml的中对AxisServlet配置的名称)
7.6    Webservice访问方式
1.    启动web服务器,或者,用axis自带的服务器,启动方式是:java -Djava.ext.dirs=lib org.apache.axis.transport.http.SimpleAxisServer -p 8080,或者把命令保存为cmd格式的文件。
2.    查看web.xml的配置。如果是:
  < servlet-mapping >
    < servlet-name > AxisServlet </ servlet-name >
    < url-pattern > /services/* </ url-pattern >
  </ servlet-mapping >
3.    通过http://localhost:8080/axis/services 访问。可以看到已经发布的webservice。
7.7    Webservice服务发布
7.7.1            发布方式
1.JWS (Java Web Service) Files - Instant Deployment
2 . Custom Deployment - Introducing WSDD
JWS 方式,部署简单,但是不能指定包名,因此不方便分类。而 Custom Deployment 方式,有更加了的灵活,可以指定包名,也可以方便的引用其它相关的类文件,对于复杂的应用非常适合。
7.7.2            wsdd文件发布
1.  修改server-config.wsdd的配置文件。它是webservice的描述文件。 如果第一次组建webservice工程,并没有这个文件,可以用下面的命令方式来生成一个。
2.  采用axis发布命令 :导航到WEB-INF/目录下 ,运行命令:java -Djava.ext.dirs=lib org.apache.axis.client.AdminClient deploy.wsdd(默认在当前目录下生成的部署描述server-config.wsdd)。
提示 :可以把上面的命令保存为cmd、dat格式的文件。准备好文件后,直接双击即可。
7.7.3            部署步骤
1. Axis命令生成部署文件。在生成全部文件时,包括了deploy.wsdd文件。
2. 执行axis发布命令或把webservice服务手工写到server-config.wsdd中。
a)      在WEB-info下面的server-config.wsdd文件包含了全部的对外发布的service。
b)      这个server-config.wsdd文件模板,可以在axis.jar解压后,来获得。或执行axis命令来产生。
c)      当web容器(web.xml中已经配置了axisServelt,同时也添加了相关jar包后),启动后,如果访问axis的相关服务,它将默认去找WEB-INF/下的 :server-config.wsdd。
7.8    Webservice测试
可以通过多种方式来测试部署的webservice,一种是VB脚本测试,或是用axis产生的testcase文件。
7.8.1            Vb脚本测试
代码实例:
Dim soapclient, result
Set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "http://134.96.71.142/QnInterface/SendMsgService.asmx?WSDL"

result = soapclient.QnSendMail_GS("zhanglelei@channelsoft.com", "", "", "")
MsgBox     "result=" & result
7.8.2            Axis生成的testcase文件测试
没有必要来单独设计一个代理类,自动生成的代码*Locator本身就是一个proxy类。
可以用axis自动生成的*testCase.java文件,通过eclipse来直接测试webservice的调用情况。
    详细参见:测试webservice 用例代码
7.9    Webservice日志跟踪
1.      使用log4j工具步骤?,
答:必须先引入相关的jar文件,然后正确的配置log4j.xml或log4j.property文件。并且放置到正确的文件夹中。
2.      log4j配置文件的选择?
答:建议采用log4j.xml文件,更加易读。
3.      在resin的conf文件中的log配置方式?
答:可以在log4j.xml文件中配置,也可以在resin.conf中配置,在<error-log id='logs/error.log'rollover-size='5MB'/>下面增加:<stdout-log id='logs/stdout.log' rollover-size='5MB'/>,就可以实现标准输出信息到stdou.log中。和在log4j.xml中的配置是也可以达到相同的效果。
4.      commons-logging.properties的作用?
答:通过配置它,可以使你方便的配置,使用不同的log工具。如果删除它,就默认使用你当前的日志工具,例如:log4j, 详细看axis中的,文件中描述。当然,可以删除这个文件,仅采用log4j工具.
5.      是否在web.xml配置?
答:如果配置文件,log4j.properties 或 log4j.xml默认是在,WEB-INF/classes下,则将不必要在web.xml文件配置,系统将自动的进行加载。
6.      如何指定日志路径?
答:指定自己指定的记录日志的包路径。如果配置级别是:debug, 只有在包为com.int97时,有debug代码时,才会向文件中输出数据。
7.      log4j.additivity.XXX= 的含义?
` 答:若为 false,表示Logger 的 appender 不继承它的父logger
若为true,则继承,这样就兼有自身的设定和父logger的设定
8       Axis集成Resin或其它应用服务器
8.1    如果配置和发布
Axis 是以 Servlet 的方式运行的,而 Resin 的作用相当于 Servlets 容器 (Container) ,因此只要配置得当,就可以使 Axis 在 Resin 环境中运行,这一点也适用于 Resin 以外的其它应用服务器 。在 Resin 中配置 Axis 的方法如下。
将 axis-1_1/webapps/axis/WEB-INF/web.xml 中的 Servlet 配置项复制到 resin.conf 中对应的 Web 应用程序配置中。通常应包括以下内容。
一个servlet可以配置多个在url地址拦访问的方式.


<!-- Axis Web-Service Configuration Start -->
<servlet>
    <servlet-name>AxisServlet</servlet-name>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AxisServlet
    </servlet-class>
</servlet>
<servlet>
    <servlet-name>AdminServlet</servlet-name>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AdminServlet
    </servlet-class>
    <load-on-startup>100</load-on-startup>
</servlet>
<servlet>
    <servlet-name>SOAPMonitorService</servlet-name>
    <display-name>SOAPMonitorService</display-name>
    <servlet-class>
        org.apache.axis.monitor.SOAPMonitorService
    </servlet-class>
    <init-param>
      <param-name>SOAPMonitorPort</param-name>
      <param-value>5001</param-value>
    </init-param>
    <load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/axis/servlet/AxisServlet</url-pattern>
</servlet-mapping>
访问方式:http:// localhost:8080/projectName/axis/servlet/AxisServlet
<servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
</servlet-mapping>
访问方式:http:// localhost:8080/projectName/*.jws
<servlet-mapping>
   <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>SOAPMonitorService</servlet-name>
    <url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<!-- uncomment this if you want the admin servlet -->
<!--
   <servlet-mapping>
     <servlet-name>AdminServlet</servlet-name>
     <url-pattern>/axis/servlet/AdminServlet</url-pattern>
   </servlet-mapping>
-->
<!-- currently the W3C havent settled on a media type for WSDL;
    http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
    for now we go with the basic 'it's XML' response -->
<mime-mapping>
    <extension>wsdl</extension>
     <mime-type>text/xml</mime-type>
</mime-mapping>

<mime-mapping>
    <extension>xsd</extension>
    <mime-type>text/xml</mime-type>
</mime-mapping>

   <!-- Axis Web-Service Configuration End -->

8.2    平台的配置方式
    < servlet >
       < servlet-name > axis </ servlet-name >      < servlet-class > org.apache.axis.transport.http.AxisServlet </ servlet-class >
       < load-on-startup > 5 </ load-on-startup >
    </ servlet >
< servlet-mapping >
       < servlet-name > axis </ servlet-name >
       < url-pattern > /webservice/* </ url-pattern >
    </ servlet-mapping >
8.3    Axis提供了哪些开发工具
Apache Axis 提供了 WSDL2Java 和 Java2WSDL 两个开发工具。
WSDL2Java 利用已知的 WSDL 文件生成服务端和客户端代码。该 WSDL 文件可以是由合作伙伴提供的,也可以是利用 Java2WSDL 生成的。 Java2WSDL 根据已有的 Java 类文件生成 WSDL 文件, Java 类文件可以是接口类文件,并不需要实现细节。
此外 Axis 还提供了 SoapMonitorApplet 和 TCPMon 工具,可用于监测 Web 服务。
8.4    生成Web服务的服务端和客户端代码
8.4.1             生成或取得WSDL文件
Java2WSDL 是 Axis 提供的利用 Java 类文件得到 WSDL 文件的工具。类文件可以使用接口文件编译生成,例如下面的接口文件 SoftwarePrice.java 。


package samples.userguide.example6;
/**
* Interface describing a web service to set and get software prices.
**/
public interface SoftwarePrice {
    public void setWidgetPrice(String softWareName, String price);
    public String getWidgetPrice(String softWareName);
编译 SoftwarePrice.java 。


javac SoftwarePrice.java
将 SoftwarePrice.class 复制到正确的 package 路径下。
执行下面的命令 :


java org.apache.axis.wsdl.Java2WSDL -o sp.wsdl -l "http://test.com:80/services/SoftwarePrice" -n "urn:SoftwarePrice"
-p"samples.userguide.example6" "urn:Example6" samples.userguide.example6.SoftwarePrice
各参数的含义如下。


-o :指定输出的WSDL文件的文件名。
-l :指定服务的位置。
-n :WSDL文件的目标名字空间。
-p :指定从package到名字空间的映射,这里可以有多个映射。
最后面的类文件包含了 Web 服务的接口。
该命令执行后,将生成 sp.wsdl 文件。
如果按 CLASSPATH 的设置找不到指定的类文件, Axis 将报告异常,如下所示。


java.lang.ClassNotFoundException: samples.userguide.example6.SoftwarePrice
        at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
        at java.security.AccessController.doPrivileged(Native Method)
……
如果出现上面的问题,请检查是否已将有关类文件复制到正确的位置或 CLASSPATH 设置是否正确。
生成 WSDL 文件以后,就可以利用 Axis 提供的 WSDL2Java 工具生成 Web 服务的服务端代码和客户端代码了。
8.4.2            注意事项
WSDL 文件也可以由合作伙伴提供。这种情况下合作伙伴往往是 Web 服务的提供者或标准接口的制定者,开发者只要按照既定的 WSDL 文件生成客户端或服务端代码就可以了。
8.4.3            生成客户端或服务端代码
WSDL2Java 工具用于从 WSDL 文件生成客户端存根( stub )代码,服务端框架( skeleton )代码以及 WSDL 中的数据类型文件 ( 生成与之对应的 Java 代码 ) 。开发人员只需向框架代码中补充相关的业务逻辑代码即可得到完整的 Web 服务代码,因此该工具极大地减轻了开发人员的编码负担。 WSDL2Java 的使用举例如下。


java org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true MyService.wsdl
执行上述命令后将生成下列文件。


No.

文件

用途
1.

deploy.wsdd

MyService 服务的部署描述文件
2.

MyService.java

MyService 服务的接口文件
3.

MyServiceService.java

获得 MyService 服务的接口文件
4.

MyServiceServiceLocator.java

实现 MyServiceService 接口
5.

MyServiceSoapBindingImpl.java

实现 MyService 接口,服务器需 要其中补充业务逻辑
6.

MyServiceSoapBindingSkeleton.java

MyService 服务的服务端框 架代码 , 实现 MyService, org.apache.axis.wsdl.Skeleton 接口
7.

MyServiceSoapBindingStub.java

MyService 服务的客户端存根代码 , 实现 MyService 接口
8.

undeploy.wsdd

注销 MyService 服务的部署描述文件
2.7.3 编写 Web 服务客户端代码
Web 服务的客户端程序完成对 Web 服务的调用,其程序结构如下。


import com.chinavnet.zx.service.v1_0.*;// WSDL2Java 生成的package的名字空间;
public class TestClient {
    public static void main (String[] args) throws Exception{
com.chinavnet.zx.service.v1_0.SPInterfaceForVNetLocator locator = new SPInterfaceForVNetLocator();// 获得一个locator对象
locator.setMaintainSession(true);
com.chinavnet.zx.service.v1_0.SPInterfaceForVNetSoap service = locator.getSPInterfaceForVNetSoap();// 获得服务对象
com.chinavnet.zx.service.v1_0.DetailLedgerFeedbackResult feedbackRes = null;
// 初始化Web服务中定义的数据类型
        try {
feedbackRes = service.generalLedgerFeedback();// 调用Web服务的方法并取得返回值
   System.out.println("FeedbackResult :");
   if(feedbackRes != null)
   {
    System.out.println("SPID: " +feedbackRes.getSPID());
    System.out.println("errorDesc: " +feedbackRes.getErrorDescription());
    System.out.println("result: " +feedbackRes.getResult());
   }else
   {
    System.out.println("feedbackRes is null!");
   }
        } catch (java.rmi.RemoteException re) {
//           throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re );
     re.printStackTrace();
        }
}//End of main()
}//End of TestClient class
测试客户端程序是非常简单的,将客户端程序编译后,执行 "java TestClient" 即可。
2.8 如何编写服务端代码
向 MyServiceSoapBindingImpl.java 添加相关的业务逻辑代码后,将 WSDL2Java 生成的源程序编译,打包成 jar 文件,复制到 /usr/local/apache/htdocs/WEB-INF/lib/ 目录下。
2.9 如何发布 Web 服务
有了 deploy.wsdd 文件并准备好类文件后,就可以发布 MyService 服务了。 Axis 在安装后自动发布了 AdminService ,利用它可以发布新的 Web 服务。方法如下。


java org.apache.axis.client.AdminClient -lhttp://localhost:80/services/AdminService deploy.wsdd
上面的命令执行后,有如下提示。
Processing file deploy.wsdd
<Admin>Done processing</Admin>
9       开发实例
9.1    Axis自带实例设置步骤
To run the address book sample, you must do the following:
1. Set up your CLASSPATH.
2. Generate the Java bindings from the AddressBook.wsdl file.
3. Compile the code.
4. Start a server.
5. Run the sample.

1. Set up your CLASSPATH.
    The CLASSPATH must contain: an XML parser (ie., Xerces), JUnit
    (www.junit.org), all the jars in the lib directory, and the directory
    containing the samples subdirectory.

2. Generate the Java bindings from the AddressBook.wsdl file.
    a. Change directory to the directory that contains the samples
        subdirectory.
    b. Run the command: java org.apache.axis.wsdl.WSDL2Java -s -d Session
        -Nurn:AddressFetcher2=samples.addr samples/addr/AddressBook.wsdl

    This will generate all the bindings, both client-side and server-side,
    into the samples/addr subdirectory.

3. Compile the code.
    a. Now you can change directory to samples/addr
    b. And compile the sample: javac *.java

4. Start a server.
    To run the sample, you will first need to run a server. To run a very
    simple server you could run, in a separate window:
        java org.apache.axis.transport.http.SimpleAxisServer -p 8080

5. Run the sample.
    Finally, to run the client, run testit.sh or testit.cmd, depending on
    your platform.
9.2    Axis开发webservice 
最近的几个项目由于涉及到不同领域 不同技术平台的应用,所以在各个系统的接口部分,采用了webservice技术,来实现不同系统的业务对接.
由于我们采用J2EE平台,下面着重讲下利用axis在J2EE平台开发和部署webservice应用的问题.
下面以一个用户登录的例子介绍开发的过程.
1.        Axis 开发包下载 .
Apache的一个项目,请下载(略)
2.        编写方法

package zpf;
import java.util.*;
import java.io.*;
public class SSOWebservice
{
   /**
      登陆并得到用户信息
   */
   Public boolean login(String loginid, String password){
      boolean ret=false;
      if(loginid.equals(“zpf”)&&password.equals(“123”))
         ret= true;
      else
         ret=false;
      return ret;

/**
    得到所有部门信息
*/
public zpf.DepartmentInfo[] getAllDepts(){
     zpf.Department dept=new zpf.Department();
        zpf.DepartmentInfo[] ret=dept.getAllDepartment();
          return ret;
}
}
http://localhost:8080/kmwhc/services/SSOWebservice
编译,通过,不在累述
3.        修改 web.xml
加入如下代码
<listener>
        <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
    </listener>
  
     <servlet>
           <servlet-name>AxisServlet</servlet-name>
           <display-name>Apache-Axis Servlet</display-name>
           <servlet-class>
               org.apache.axis.transport.http.AxisServlet
           </servlet-class>
     </servlet>
  <servlet>
    <servlet-name>AdminServlet</servlet-name>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AdminServlet
    </servlet-class>
    <load-on-startup>100</load-on-startup>
</servlet>
  <servlet>
    <servlet-name>SOAPMonitorService</servlet-name>
    <display-name>SOAPMonitorService</display-name>
    <servlet-class>
        org.apache.axis.monitor.SOAPMonitorService
    </servlet-class>
    <init-param>
      <param-name>SOAPMonitorPort</param-name>
      <param-value>5001</param-value>
    </init-param>
    <load-on-startup>100</load-on-startup>
</servlet>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
</servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>
  <servlet-mapping>
    <servlet-name>SOAPMonitorService</servlet-name>
    <url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
  <!-- uncomment this if you want the admin servlet -->
    <!-- currently the W3C havent settled on a media type for WSDL;
    http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
    for now we go with the basic 'it's XML' response -->
<mime-mapping>
    <extension>wsdl</extension>
     <mime-type>text/xml</mime-type>
</mime-mapping>
    <mime-mapping>
    <extension>xsd</extension>
    <mime-type>text/xml</mime-type>
</mime-mapping>
4.        布署
(1)    WEB-INF下建立文件server-config.wsdd
(2)    文件内容如下:
蓝色部分定义了服务的名称,所用的类 方法.
红色部分定义了服务的方法所用的返回值的自定义类型.
<?xml version="1.0" encoding="gb2312"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  
       <globalConfiguration>
              <parameter name="adminPassword" value="admin"/>
              <parameter name="enableNamespacePrefixOptimization" value="true"/>
              <parameter name="attachments.Directory" value="D:/jakarta-tomcat-5.0.28/webapps/axis/WEB-INF/attachments"/>
              <parameter name="disablePrettyXML" value="true"/>
              <parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
              <parameter name="sendXsiTypes" value="true"/>
              <parameter name="sendMultiRefs" value="true"/>
              <parameter name="sendXMLDeclaration" value="true"/>
              <requestFlow>
                     <handler type="java:org.apache.axis.handlers.JWSHandler">
                            <parameter name="scope" value="session"/>
                     </handler>
                     <handler type="java:org.apache.axis.handlers.JWSHandler">
                            <parameter name="scope" value="request"/>
                            <parameter name="extension" value=".jwr"/>
                     </handler>
              </requestFlow>
       </globalConfiguration>
    <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
       <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
       <handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
<!-- 自定义服务开始 -->
<!-- 单点登陆服务 add by Zhang.P.F -->
<service name="SSOWebservice" provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="zpf.SSOWebservice"/>
<operation name="login" returnType="ns:boolean">
    <parameter name="loginid" type="ns:String"/>
       <parameter name="password" type="ns:String"/>
</operation>
<operation name="getAllDepts" returnType="ns:ArrayOf_tns2_DepartmentInfo">
   </operation>
<typeMapping
        xmlns:ns="http://interf.kmwhc.zpf.com"
        qname="ns:DepartmentInfo"
        type="java:zpf.DepartmentInfo"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
/>
<typeMapping
        xmlns:ns="urn:SSOWebservice"
        qname="ns:ArrayOf_tns2_DepartmentInfo"
        type="java:zpf.DepartmentInfo[]"
        serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
        deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
  </service>
<!-- 自定义服务结束 -->
    <service name="AdminService" provider="java:MSG">
              <parameter name="allowedMethods" value="AdminService"/>
              <parameter name="enableRemoteAdmin" value="false"/>
              <parameter name="className" value="org.apache.axis.utils.Admin"/>
              <namespace>http://xml.apache.org/axis/wsdd/</namespace>
              <namespace>http://xml.apache.org/axis/wsdd/</namespace>
       </service>
    <service name="Version" provider="java:RPC">
              <parameter name="allowedMethods" value="getVersion"/>
              <parameter name="className" value="org.apache.axis.Version"/>
       </service>
    <transport name="http">
              <requestFlow>
                     <handler type="URLMapper"/>
                     <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
              </requestFlow>
              <parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
              <parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
              <parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
              <parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
              <parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
              <parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
       </transport>
    <transport name="local">
              <responseFlow>
                     <handler type="LocalResponder"/>
              </responseFlow>
       </transport>
</deployment>
文件修改完毕后,重新启动你的应用服务器.
5.        测试
在IE里输入http://localhost:8080/kmwhc/services/SSOWebservice 看到页面提示如下信息表示布署成功:
SSOWebservice
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
6.     编译生成客户端调用包
   我用的ANT进行编译,在配置文件里加入如下代码
<!--登录服务-->
       <java2wsdl output="${client.dir}/SSOWebservice.wsdl"
           className="zpf.SSOWebservice"
           namespace="urn:SSOWebservice"
           location="http://localhost:8080/kmwhc/services/SSOWebservice">
           <mapping namespace="urn:SSOWebservice"
              package="zpf.client" />
       </java2wsdl>
       <wsdl2java url="${client.dir}/SSOWebservice.wsdl"
           output="${client.dir}" deployscope="session" serverSide="yes"
           skeletonDeploy="no" noimports="no" verbose="no" testcase="no">
           <mapping namespace="urn:SSOWebservice"
              package="zpf.client" />
       </wsdl2java>
编译,生成wsdl文件和客户端代码.
7调用代码:
zpf.client.SSOWebserviceServiceLocator sv=new zpf.client. SSOWebserviceServiceLocator();
zpf.client.SSOWebservice ssp=sv.getWebCaseservice(new java.net.URL("http://localhost:8080/kmwhc/services/SSOWebservice"));
   boolean aa=ssp.login( “admin”,”123”);
10            相关文章
10.1       AXIS详细介绍
A pache Axis 是Apache WebService项目中的子项目,其最初起源于IBM的"SOAP4J",应该属于最早的一批用于构造基于SOAP应用的Framework。目前Apache Axis已经发展到了第三代,其核心是一个SOAP处理器,用于开发包括客户端,服务器端,SOAP Gateway等各种应用。事实上Apache Axis在了1.0版后,其发行版本还包括了完整的J2EE服务器插件, WSDL支持和生成,TCP/IP监视器等组件,从这个意义上来说Apahce Axis已不仅仅是个SOAP框架了,它包含了除了UDDI外对整个Web Service协议栈(Protocol Stack)的支持。
       AXIS 研究的时间不长,在下在到的AXIS包中有一个类叫WSDL2Java,从字面意思就能够理解到这个工具是做什么的。既:提供要调用的webservice 描述WSDL,然后生成调用的时候需要的JAVA程序,目前为止我也是只研究到这,因为我们在调用另一个公司提供的webservice的时候对方返回的信息就是dataset,我用soap的方法已经没有办法实现了(后来调查是可以实现的,但是相当麻烦),经商议以后决定修改对方的 webservice,将返回的dataset强制tostring,然后再返回到JAVA中作处理。虽然解决了问题,但是改动对方的 webservice有损webservice的意义,所以就使用了AXIS。从网上查资料的时候查到了WSDL2JAVA这个类。
对于编写基于AXIS方法能够调用.NET的JAVA程序,你必须有一下几个工具:
1、 操作系统
2、 JDK(我使用的是j2sdk1.4.2)
3、 axis.jar
      Axis-schema.jar 在 1.3 的版本中有这个文件。
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
log4j-1.2.8.jar
name.txt
saaj.jar
wsdl4j.jar
4、 集成开发环境(我的是Eclipse3.1.1)
将axis包中的jar文件存到jdk下面,在windows控制台中进入jdk目录,然后运行
Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java http://localhost/Add.asmx?wsdl 命令,注意: http://localhost/Add.asmx?wsdl 是你要的文件调用的webservice程序的地址,就是上文说到的那个wsdl文件,如果java环境没有问题的话,wsdl2java就应该将生成的java文件包,存放到jdk主目录下面。你的第一步成功了,生成的文件就能够实现粗略的功能了。
WSDL2Java 生成的文件总结如下:
Client-side Bindings :
Sample:    java org.apache.axis.wsdl.WSDL2Java AddressBook.wsdl


WSDL 子句

生成的 Java 类
为在 type 区的每个条目

一个 Java 类
一个 Holder 类,如果此 type 被用作 inout/out 参数
为每个 portType

一个 Java 接口
为每个 binding

一个 Stub 类
为每个 service

一个 service 接口
一个 service 实现 ( 作为定位器 )

Server-side Bindings :
Sample: java org.apache.axis.wsdl.WSDL2Java --server-side AddressBook.wsdl


WSDL 子句

生成的 Java 类
为每个 binding

一个 Skeleton 类 ( 若 —skeletonDeploy 设为 true 时 )
一个实现模板类 ( 供用户修改为自己的实现 )
为所有的 services

一个 deploy.wsdd 文件
一个 undeploy.wsdd 文件

命令参数参考:
Usage:
  java org.apache.axis.wsdl.WSDL2Java [options] WSDL-URI
Options:
-h, --help
打印帮助信息后退出
-v, --verbose
打印报告信息
-n, --noImports
只生成直接的WSDL代码文档
-O, --timeout <argument>
超时秒数(默认45秒, -1表示不限定)
-D, --Debug
打印调试信息
-W, --noWrapped
关闭装订(wrapped)文档/文字支持
-s, --server-side
为web service发布服务端绑定
-S, --skeletonDeploy <argument>
在deploy.wsdd中展开纲要(true)或执行(false)。
默认为false。假定server-side.
-N, --NStoPkg <argument>=<value>
命名空间到包的映射
-f, --fileNStoPkg <argument>
命名空间到包的映射文件(默认为NStoPkg.properties)


-p, --package <argument>
用包名称覆盖所有的命名空间到包的映射
-o, --output <argument>
发行文件的输出目录
-d, --deployScope <argument>
增加范围到deploy.xml: Application(应用), Request(请求), Session(会话)
-t, --testCase
为web service发行junit测试用例类
-a, --all
为所有元素生成代码,包括未引用的元素
-T, --typeMappingVersion
指示1.1或1.2版. 默认为1.1版(SOAP 1.1适用JAX-RPC. 1.2标志SOAP 1.1编码.)
-F, --factory <argument>
执行GeneratorFactory接口的用户类名称(扩展Java generation函数)
-i, --nsInclude <namespace>
包含在生成代码中的特定命名范围(默认为所有命名空间,除非用-x选项)
-x, --nsExclude <namespace>
从生成代码中排除的特定命名空间(默认为none,排除直到第一个用-i选项包含的命名空间)
-p, --property <name>=<value>
用户GeneratorFactory的属性名称和值
-H, --helperGen
为meta数据发行分离Helper类
-U, --user <argument>
访问WSDL-URI的用户名
-P, --password <argument>
访问WSDL-URI的密码
-c, --implementationClassName <argument> 用该项作为实现类
假如我要调用的webservice中的laiheng方法,在生成的文件中就有LaihengResponseLaihengResult.Java文件,其中有一块是这样写的:
    public LaihengResponseLaihengResult(
           org.apache.axis.message.MessageElement [] _any) {
           this._any = _any;
}
_any中就有你要的结果了。
写到这里暂时就算写完了吧,其实有好多要写的东西,我这人比较懒,写一篇能够引导新手不走弯路的文章的出发点应该是好的。可是写到这后就没有时间和想法继续写下去了。如果要是看到这篇文章后不明白的地方或者是我写错的地方,请指正。
我的电子邮件是:TTYsonic#gmail.com
10.2       使用 Handler 来增强 Web 服务的功能
axis版本是apache axis-bin-1_3,可以到apache网站下载。
10.2.1      环境变量设置
AXIS_HOME
即axis-bin-1_2.zip解压的目录(我的是在 F:/opensource/axis-1_2)
   AXIS_LIB
即 %AXIS_HOME%/lib
10.2.2      导入jar包
将axisa解压缩后,复制lib目录下列jar包到应用目录的lib目录:
saaj.jar
wsdl4j-1.5.1.jar
jaxrpc.jar
commons-logging-1.0.4.jar
commons-discovery-0.2.jar
axis-schema.jar
axis-ant.jar
axis.jar
10.2.3      修改web.Xml
将 axis 需要的 servlet 复制到应用的 web.xml 文件里面,注意顺序。重新启动服务,可以访问 “/servlet/AxisServlet” 试一下,比如: http://10.162.11.70:9080/newsdaoa/servlet/AxisServlet 。   详细参见 web.xml 配置文件。
10.2.4      添加服务
将server-config.wsdd文件复制到发布应用的WEB-INF目录下,这就是AXIS的配置文件,以后所有的服务发布描述都会在里面找到。
如果还没有server-config.wsdd文件,可以先写一个发布描述文件,然后用axis来生成,以后需要发布新的服务,直接往里面添加即可。
比如有一个HelloWorld.class类,里面有sayHello(String msg)方法,想把它发布webservices,先写发布文件deploy.wsdd文件,即SOAP服务发布描述文件deploy.wsdd
http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java ">
进入dos窗口,执行下列命令:
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd 即可生成server-config.wsdd文件。
如果想发布新的服务,直接往server-config.wsdd里面添加 service描述,比如想把知识管理模块导入知识功能发布成webservices,对应的程序文件是 com.lc.v3.ecp.km.inteface.KmDelegate.java,需要发布的方法是importKm(String kmXmlStr),将此文件编译成class后,放到发布系统的相应目录下,往server-config.wsdd添加下列描述:
重新启动服务,一个新的webservices就发布成功了,如果系统发布地址是http://10.162.11.70:9080/newsdaoa ,
调用的url是:http://10.162.11.70:9080/newsdaoa/services/ImportKm
10.2.5      给服务添加Handler
J2EE Web 服务中的Handler技术特点非常像Servlet技术中的Filter。我们知道,在Servlet中,当一个HTTP到达服务端时,往往要经过多个 Filter对请求进行过滤,然后才到达提供服务的Servlet,这些Filter的功能往往是对请求进行统一编码,对用户进行认证,把用户的访问写入系统日志等。相应的,Web服务中的Handler通常也提供一下的功能:
对客户端进行认证、授权;
把用户的访问写入系统日志;
对请求的SOAP消息进行加密,解密;
为Web Services对象做缓存。
SOAP消息Handler能够访问代表RPC请求或者响应的SOAP消息。在JAX-RPC技术中,SOAP消息Handler可以部署在服务端,也可以在客户端使用。
至于如何开发handler,可以到网上去搜索陈亚强写的《使用Handler来增强Web服务的功能》,人家写的比较好,我就不在这废话了。
比如服务必须有用户名和密码才能访问,可以添加axis自带的检验认证handler,用户名和密码存放在/WEB-INF下的users.lst文件中。handler分别是:
//访问者必须提供用户名和密码,只要用户名和密码正确即可
org.apache.axis.handlers.SimpleAuthenticationHandler
//访问者必须提供指定的用户名和密码,用户名和密码正确即可
//在services中用allowedRoles属性指定访问的用户名
org.apache.axis.handlers.SimpleAuthorizationHandler
如果想给上面的ImportKm服务添加用户校验,并且只允许用户是pubnet,密码是123456的用户访问,首先往users.lst添加用户名和密码,格式是:
pubnet 123456
user1 pass1
user2
user3 pass3
11            常见问题和解答
1. 通过build.xml文件,根据java文件来生成wsdl文件(即:java2wsdl)生成的文件中,相关的参数名称和java文件中的webservice函数的参数名称不对应,但是,可以使用,如何解决?
答:通过试验,可能是axis本身的一个bug。但是,如果通过修改server-config.wsdd文件,把相关的webservice函数添加到该文件中,然后通过启动服务,来获得wsdl文件,参数名称都和java类中webservice函数参数相互对应。建议,采用修改server- config.wsdd文件。
2. 启动axis本身自带的axis server时,总是产生警告:Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled ?
答:可以添加两个jar文件:mailapi_1_3_1.jar, activation.jar 。详细参见:
http://www.cppblog.com/wform/archive/2006/04/27/mail_activation_jar.html 这个是可以忽略的。不过以后构建web services都要用到的,还是添加上的好。
3. 青牛和97营业系统交互的webservice的部署方式?
答:相同的一个应用,但是青牛和97的IP地址是不同的。
青牛的访问地址: http://134.96.71.13:8080/axis/ 
97 的访问地址:http:// 134.96.4.3:8080/axis
4. 
12            参考资源
1. Axis官方网站的帮助文档 参见axis官方网站。http://ws.apache.org/
2. 网络相关的文档
3.  http://134.96.71.13:8080/axis/ 青牛和97营业系统的webservice部署地址。
4. Spring+Axis2的开发和使用指南。
13            总结和展望
1. 这是个详细的版本。以后发布一个简单版,可以通过短短的100多个字,可以完成全部的操作。
2. 可以采用axis2,新的架构,更好的文档。详细axis官方网站。
感谢网上的相关资源。
14            附录
14.1       测试webservice用例代码
在zj114boss_new、dxmp工程中,有源代码可以参照。很好的方式。
/**
     *
     * @throws RemoteException
     * @author zhanglelei
     * @date 2006-11-23 16:43:56
     */
    public void testQnSendMail2() throws RemoteException {
       String soapAddress = "http://134.96.71.142/QnInterface/SendMsgService.asmx";
       try {
           URL endpoint = new URL(soapAddress);
           // Create proxy class
           SendMsgServiceLocator sendMsgServiceLocator = new SendMsgServiceLocator();
         
           // Get the implementation class of the webservice
           SendMsgServiceSoapStub sendMsgServiceSoapStub = (SendMsgServiceSoapStub)sendMsgServiceLocator.getSendMsgServiceSoap(endpoint);
         
           // Finish actual action
           int retVal = sendMsgServiceSoapStub.QnSendMail("zhanglelei@channelsoft.com", "1", "1", "1");
         
           System.out.println(" 动态调用发送邮件接口返回值为:" + retVal);
       } catch (ServiceException e) {
           e.printStackTrace();
       } catch (MalformedURLException e1) {
           e1.printStackTrace();
       }
    }
14.2       build.xml脚本代码
在这里增加了详细的注释。基本覆盖了axis全部使用方式。
<?xml version="1.0" ?>
<!DOCTYPE project [
        <!ENTITY properties SYSTEM "file:../xmls/properties.xml">
        <!ENTITY paths SYSTEM "file:../xmls/path_refs.xml">
        <!ENTITY taskdefs SYSTEM "file:../xmls/taskdefs.xml">
        <!ENTITY taskdefs_post_compile SYSTEM "file:../xmls/taskdefs_post_compile.xml">
        <!ENTITY targets SYSTEM "file:../xmls/targets.xml">
]>

<!-- ===================================================================
<description>
   Component file for Axis
Notes:
   This is a build file for use with the Jakarta Ant build tool.
Prerequisites:
   jakarta-ant from http://jakarta.apache.org
Build Instructions:
   To wsdl2java
        ant wsdl2java
Author:
   lanning thunder4393@gmail.com zhanglelei@channelsoft.com

Copyright:
Copyright (c) 2002-2003 Apache Software Foundation.
</description>
==================================================================== -->
<!-- ====================================================================
    1. You may use service interface to generate wsdl and other code files with <target name="java2wsd">
    2. You also may use wsdl to generate code files and wsdd file with <target name="java2wsd">
    ====================================================================
-->
<!-- basedir is a build-in properties, it may directly be ${basedir}-->
<project default="wsdl2java" basedir="." >

<property name="axis.home" location=".." />
  
<property name="app.name" value="axis" />
  
<property name="componentName" value="com/int97" />

<property name="dev.dir" location="${basedir}" />

<property name="dev.classes.dir" location="${axis.home}/webapps/axis/WEB-INF/classes" />

<path id="dev.classpath">
    <pathelement path="${dev.classes.dir}"/>
</path>

<path id="axis.classpath">
    <fileset dir="${axis.home}/webapps/axis/WEB-INF/lib">
       <include name="**/*.jar" />
    </fileset>
</path>  
  
<path id="all.classpath">
    <path refid="axis.classpath"/>
    <pathelement location="${dev.classes.dir}" />
</path>  

<!-- the <taskdef> declaration to declare all the tasks listed in a properties file
     inside the axis-ant.jar file
     other definition method:
          <taskdef name="axis-java2wsdl" classname="org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask"
           loaderref="axis" >
               <classpath refid="classpath.id"/>
        </taskdef>
-->
<taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />

        &properties;
        &paths;
        &taskdefs;
        &taskdefs_post_compile;
        &targets;

<target name="clean"/>

<target name="copy" depends="setenv"/>
  
<!-- =================================================================== -->
<!-- Set relevant parameters for concrete application
     for example:
        1. set wsdl file name
        2. set mapping's package name
        3. wsdl2java's properties need to refer the axis docs -->
<!-- =================================================================== -->
<target name="wsdl2java">
    <echo message="Generating java files from wsdl"/>
    <wsdl2java url="${dev.dir}/OpenBusinessService.wsdl"
               output="${dev.dir}"
               deployscope="session"
               serverSide="yes"
               skeletonDeploy="yes"
               noimports="no"
               verbose="yes"
               typeMappingVersion="1.1"
               testcase="yes">
            <mapping namespace="http://134.96.71.13:8080/axis/OpenBusinessService.wsdl" package="com.int97.webserviceclient"/>
        </wsdl2java>
</target>
  
<!-- axis-java2wsdl is a taskdefing the public Axis taskdefs in the axis-tasks.properties-->
<target name="java2wsdl">
    <echo message="Generating java files from wsdl"/>
    <!-- <java2wsdl> is equal with <axis-java2wsdl>-->
    <axis-java2wsdl output="${dev.dir}/OpenBusinessServiceTest.wsdl"
                  classname="com.int97.test.OpenBusinessService"
                  location="http://localhost:8080/axis/services/OpenBusinessService"
                  namespace="urn:OpenBusinessService"
                  style="RPC" >
                  <!-- classpath is neccesary, otherwise, <java2wsdl> won't find the class.
                  <classpath refid="all.classpath" /> -->
                  <classpath path="${dev.classes.dir}" />
    </axis-java2wsdl>
</target>

  
<!-- Deprecated
<target name="compile" depends="copy">

<javac srcdir="${axis.home}" destdir="${build.dest}" debug="${debug}" nowarn="${nowarn}" source="${source}" fork="${javac.fork}">
    <classpath>
        <path refid="classpath"/>
    </classpath>
    <include name="samples/addr/**/*.java"/>
    <exclude name="samples/addr/*.java" />
    <exclude name="samples/**/*SMTP*.java" unless="smtp.present" />
    <exclude name="**/old/**/*.java" />
</javac>

    <wsdl2java url="${axis.home}/samples/addr/AddressBook.wsdl"
               output="${build.dir}/work"
               deployscope="session"
               serverSide="yes"
               skeletonDeploy="yes"
               noimports="no"
               verbose="no"
               typeMappingVersion="1.1"
               testcase="no">
        <mapping namespace="urn:AddressFetcher2" package="samples.addr"/>
    </wsdl2java>

    <copy todir="${build.dir}/work/samples/addr" overwrite="yes">
      <fileset dir="${axis.home}/samples/addr">
        <include name="Main.java"/>
        <include name="DOMUtils.java"/>
        <include name="AddressBookSOAPBindingImpl.java"/>
      </fileset>
    </copy>

       Compile the echo sample generated java files
    <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}" nowarn="${nowarn}" source="${source}" fork="${javac.fork}">
      <classpath refid="classpath" />
      <include name="samples/addr/**.java" />
    </javac>

</target>
-->
  
<!-- Use this file to undeploy some handlers/chains and services    -->
<!-- Two ways to do this:                                           -->
<!--   java org.apache.axis.client.AdminClient undeploy.wsdd        -->
<!--      after the axis server is running                          -->
<!-- or                                                             -->
<!--   java org.apache.axis.utils.Admin client|server undeploy.wsdd -->
<!--      from the same directory that the Axis engine runs         -->

<!-- ???AdminService is setted in the server-config.wsdd, it's class is
     org.apache.axis.utils.Admin
    
     servletpath the path to the AxisAdmin servlet
     url full url to the admin endpoint 
-->
<target name="deploy">
    <axis-admin port="8080" hostname="localhost" failonerror="true"
       servletpath="${app.name}/services/AdminService" debug="true"
       xmlfile="${basedir}/deploy.wsdd" />
</target>
  
<target name="undeploy">
    <axis-admin port="8080" hostname="localhost" failonerror="true"
       servletpath="${app.name}/services/AdminService" debug="true"
       xmlfile="${basedir}/undeploy.wsdd" />
</target>
  
<!--<target name="run"/> -->

<!-- <target name="undeploy"/> -->

<!-- ============================================
          Reference Resource
    ============================================
    target name="j2w-nicethingsbean">
        <axis-java2wsdl   classname="samples.ejb.NiceThingsBean"
           methods="sayHello,findNiceThingsFor,updateNiceThingsFor"
                        output="nicethings.wsdl"
                        location="http://localhost:8080/axis/services/NiceThingsBean"
                        namespace="http://localhost:8080/axis/services/NiceThingsBean"
                        namespaceImpl=
                            "http://localhost:8080/axis/services/NiceThingsBean">
            <complextype classname="samples.ejb.NiceThings"
                         namespace="urn:NiceThingsBean"/>
< You can also pass in another serializer/deserializer if you don't want to use the default
        BeanSerializerFactory for a particular complextype
                 serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
                 deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" >
        </axis-java2wsdl>
    </target> 
-->
</project>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics