我们通过书写wsdd文件来生成 webservice 的服务器端。要注意其书写的方式
@echo off set AXIS_HOME=D:\workspace\testServices\WebRoot\WEB-INF rem set AXIS_HOME cd %AXIS_HOME% rem echo current dir=%cd% set JAVA_HOME=D:\MyEclipse 6.5\jre rem set JAVA_HOME set CLASSPATH=%JAVA_HOME%\lib\tools.jar set CLASSPATH=.;%CLASSPATH% set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\activation.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\axis.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\axis-ant.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\commons-discovery-0.2.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\commons-logging-1.0.4.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\jaxrpc.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\log4j-1.2.8.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\mail.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\saaj.jar set CLASSPATH=%CLASSPATH%;%AXIS_HOME%\WebRoot\WEB-INF\lib\wsdl4j-1.5.1.jar rem set CLASSPATH set _RUNJAVA="%JAVA_HOME%\bin\java" set _RUNJAVAW="%JAVA_HOME%\bin\javaw" set _RUNJDB="%JAVA_HOME%\bin\jdb" set _RUNJAVAC="%JAVA_HOME%\bin\javac" set OUTPUT_PATH=%AXIS_HOME%\src echo 开始执行wsddjava... java -Djava.ext.dirs=lib org.apache.axis.client.AdminClient -l http://localhost:8080/testServices/services/PolicyInfoService deploy.wsdd echo ...执行wsdd java完成 pause -lhttp://localhost:8080/testServices/services/AdminService deploy.wsdd
比如,我们部署的文件名称是 deploy.wsdd 以上命令就是利用了 AXIS 提供的一个AdminClient 工具类。它来生成 服务器 端的配置。
deploy.wsdd 文件如下:
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <!-- Services from YwxCommonService WSDL service --> <service name="PolicyInfoService" provider="java:RPC" style="wrapped" use="literal"> <parameter name="className" value="server.SayHello"/> <parameter name="allowedMethods" value="getPolicyInfo"/> <parameter name="wsdlTargetNamespace" value="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx"/> <parameter name="schemaQualified" value="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx,http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"/> <parameter name="wsdlServiceElement" value="PolicyInfoService"/> <parameter name="wsdlServicePort" value="PolicyInfoService"/> <parameter name="wsdlPortType" value="PolicyInfoCommService"/> <parameter name="typeMappingVersion" value="1.2"/> <operation name="getPolicyInfo" qname="operNS:getPolicyInfo" xmlns:operNS="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx" returnQName="retNS:musterCollectResponse" xmlns:retNS="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx" returnType="rtns:MusterCollectResponse" xmlns:rtns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types" soapAction="" > <parameter qname="pns:musterCollectRequest" xmlns:pns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx" type="tns:MusterCollectRequest" xmlns:tns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"/> </operation> <typeMapping xmlns:ns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types" qname="ns:MusterCollectRequest" type="java:com.cpic.b2bcore.externalinterface.wss.type.MusterCollectRequest" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> <typeMapping xmlns:ns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types" qname="ns:MusterCollectResponse" type="java:com.cpic.b2bcore.externalinterface.wss.type.MusterCollectResponse" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="" /> </service> </deployment>
定义WEBSERVICE名称。
<service name="PolicyInfoService" provider="java:RPC" style="wrapped" use="literal">
实现类文件
<parameter name="className" value="server.SayHello"/>
调用方法
<parameter name="allowedMethods" value="getPolicyInfo"/>
命名空间,定义之后,生成的客户端文件按照这个包名存放 ,这里,类型文件存放在 /type下。
<parameter name="wsdlTargetNamespace" value="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx"/>
<parameter name="schemaQualified" value="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx,http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"/>
这里随意定义
<parameter name="wsdlServiceElement" value="PolicyInfoService"/>
<parameter name="wsdlServicePort" value="PolicyInfoService"/>
<parameter name="wsdlPortType" value="PolicyInfoCommService"/>
<parameter name="typeMappingVersion" value="1.2"/>
这里填写方法名称:
<operation name="getPolicyInfo" qname="operNS:getPolicyInfo"
要和上面定义的空间名称一致。
xmlns:operNS="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx"
returnQName="retNS:musterCollectResponse" xmlns:retNS=http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx
定义返回类型:
returnType="rtns:MusterCollectResponse" xmlns:rtns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types" soapAction="" >
定义参数类型:
<parameter qname="pns:musterCollectRequest" xmlns:pns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx"
type="tns:MusterCollectRequest" xmlns:tns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"/>
</operation>
定义影射:要和上面定义的空间名称一致
<typeMapping
xmlns:ns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"
qname="ns:MusterCollectRequest"
type="java:com.cpic.b2bcore.externalinterface.wss.type.MusterCollectRequest"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
定义影射:要和上面定义的空间名称一致
<typeMapping
xmlns:ns="http://wss.cpic.com.cn/propertyinsurance/commonservice/ywx/types"
qname="ns:MusterCollectResponse"
type="java:com.cpic.b2bcore.externalinterface.wss.type.MusterCollectResponse"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>