WebService核心文件【web-config.wsdd】调用操作
标签:发布 response bar detail 技术分享 准备工作 namespace deploy simple
WebService核心文件【server-config.wsdd】详解及调用示例
作者:玛莎拉蒂-小贱人
一、准备工作
导入需要的jar包:
二、配置web.xml
在web工程的web.xml中添加如下配置:
[html] view plain
copy
- servlet>
- servlet-name>AxisServletservlet-name>
- servlet-class>org.apache.axis.transport.http.AxisServletservlet-class>
- load-on-startup>15load-on-startup>
- servlet>
- servlet-mapping>
- servlet-name>AxisServletservlet-name>
- url-pattern>/services/*url-pattern>
- servlet-mapping>
三、配置server-config.wsdd文件
在WEB-INF下添加WebService核心文件server-config.wsdd:
[html] view plain
copy
- 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="D:\myproject\calileo\xxx\WebContent\WEB-INF\attachments" />
- parameter name="dotNetSoapEncFix" value="true" />
- parameter name="enableNamespacePrefixOptimization" value="true" />
- parameter name="sendXMLDeclaration" value="true" />
- parameter name="attachments.implementation"
- value="org.apache.axis.attachments.AttachmentsImpl" />
- parameter name="sendXsiTypes" 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" />
-
-
- service name="SjrkkService" provider="java:RPC">
-
- parameter name="className" value="com.xxx.ws.SjrkkService" />
- 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>
四、测试WSDL
在浏览器输入:http://localhost:8080/xxx/services/SjrkkService?wsdl //xxx和server-config.wsdd文件中的xxx一致,访问结果如下:
五、调WebService
[java] view plain
copy
- /**
- * 调用webservice的方法.
- * @param url wsdl链接
- * @param method 调用的接口
- * @param idCard 传入的参数
- * @return
- * @throws Exception
- */
- private String getWebServiceResult( String url, String method, String idCard) throws Exception{
- String rtnXml = null;
- try {
- String endpoint = url;
- Service service = new Service();
- Call call = (Call) service.createCall();
-
- call.setTargetEndpointAddress(new java.net.URL(endpoint));
- call.setOperationName(method);
-
- rtnXml = (String) call.invoke(new Object[]{idCard});
-
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return rtnXml;
- }
WebService核心文件【web-config.wsdd】调用操作
标签:发布 response bar detail 技术分享 准备工作 namespace deploy simple
原文地址:http://www.cnblogs.com/liujian-java/p/7326936.html
评论