第一个的 webservice 实例
超简单,才 5 步
1> 获取 axis 及关联的 jar 包
http://dl.iteye.com/topics/download/6a76de1e-d506-35bc-a41b-508d4be04025
2> 新建一个模拟服务 java 类
package server;
public class SayHello {
public String getName(String name) {
return "你好," + name;
}
}
3> 在 web.xml 下新增一个 servelt
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
4> 在 web 项目的 web.xml 同目录新建文件 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="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"/>
</globalConfiguration>
<handler type="java:org.apache.axis.handlers.http.URLMapper" name="URLMapper"/>
<service name="Login.jws" provider="java:RPC">
<parameter name="className" value="server.SayHello"/>
<parameter name="scope" value="request"/>
评论0
最新资源