首页 > 学院 > 开发设计 > 正文

WEB Service配置

2019-11-06 06:19:00
字体:
来源:转载
供稿:网友

 一.WEB.xml配置

 <!--axisstart-->  <servlet>    <servlet-name>AxisServlet</servlet-name>    <display-name>Apache-Axis Servlet</display-name>    <servlet-class>        org.apache.axis.transport.http.AxisServlet    </servlet-class>  </servlet>

  <!--axismappingstart-->   <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>

二、配置server-config.wsdd文件

<?xml version="1.0" encoding="UTF-8"?><deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/PRoviders/java"> <globalConfiguration>  <parameter name="sendMultiRefs" value="true"/>  <parameter name="disablePrettyXML" value="true"/>  <parameter name="adminPassWord" value="admin"/>  <parameter name="attachments.Directory" value="./attachments"/>  <parameter name="dotNetSoapEncFix" value="true"/>  <parameter name="enableNamespacePrefixOptimization" value="false"/>  <parameter name="sendXMLDeclaration" value="true"/>  <parameter name="sendXsiTypes" value="true"/>  <parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>  <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="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/> <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/> <handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/> <service name="CTPIHKRepuOfClaimsApproval" provider="java:RPC">  <parameter name="allowedMethods" value="*"/>  <parameter name="scope" value="request"/> <!-- 核心重点:服务发布,name:表示发布的service名 -->   <!-- 发布的service接口类 -->  <parameter name="className" value="com.xxx.application.ws.CTPIHKRepuOfClaimsApproval"/> </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> <service name="PacgServices" provider="java:RPC">     <parameter name="className" value="com.xxx.application.common.PacgServices"/>     <parameter name="scope" value="request"/>     <parameter name="allowedMethods" value="newService"/>     <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> </service>          <service name="CoreForMaterialServices" provider="java:RPC">     <parameter name="className" value="com.xxx.application.common.CoreForMaterialServices"/>     <parameter name="scope" value="request"/>     <parameter name="allowedMethods" value="*"/>     <beanMapping qname="myNS:GoMaterialMainVo" xmlns:myNS="urn:GoMaterialMainVo"             languageSpecificType="java:com.xxx.application.prpall.dto.custom.GoMaterialMainVo"/>     <beanMapping qname="myNS:GuTdtaskVo" xmlns:myNS="urn:GuTdtaskVo"             languageSpecificType="java:com.xxx.application.prpall.dto.custom.GuTdtaskVo"/>     <arrayMapping qname="myNS:T_ImgPropertyVos" xmlns:myNS="urn:T_ImgPropertyVos"        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"         serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"      languageSpecificType="java:com.xxx.application.prpall.dto.custom.T_ImgPropertyVo[]"/>               <beanMapping qname="myNS:T_ImgPropertyVo" xmlns:myNS="urn:T_ImgPropertyVo"             languageSpecificType="java:com.xxx.application.prpall.dto.custom.T_ImgPropertyVo"/>      <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> </service>   <transport name="http">  <requestFlow>   <handler type="URLMapper"/>   <handler type="java:com.xxx.application.ws.HTTPAuthHandlerWithLog"/>  </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>

三.java文件

String wsdl = "http://10.XXX.XXX.228:8XXX/services/PacgServices?wsdl"; String namespace = "http://10.XXX.XXX.228:8XXX/services/PacgServices";*	   	// 参数名String pname = "xml"; // 方法名 String mname = "newService";String soapuri =""; Service service = new Service();Call call = (Call) service.createCall();call.setTargetEndpointAddress(wsdl);call.setOperationName(new javax.xml.namespace.QName(namespace,mname));call.setSOAPActionURI(soapuri);call.setEncodingStyle(null);call.addParameter(new javax.xml.namespace.QName(namespace, pname),			org.apache.axis.encoding.XMLType.XSD_STRING,			javax.xml.rpc.ParameterMode.IN);call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);call.setTimeout(300000);
Packet packet = new Packet();//报文对象packet.setType("Request");		packet.setHead("taskId", taskId);packet.setBodyList("TemporaryTable_List", "TemporaryTable",lists);	String xml=packet.toXml();						
String xml=packet.toXml();//
String result = (String) call.invoke(new Object[] { xml });		


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表