1、服务端
这次要发布的web service非常简单。它的功能是把从客户端传入的字符串中的小写字母转变成大写字母,再返回给客户端。
Soap 服务器采用apache的AXIS(可以从http://ws.apache.org/axis/下载),应用服务器可以选用各种servlet 容器,我这里采用的是weblogic。
1.1 实现类的源代码:
// StringProcessor.java
package com.jagie.j2me.ws;
public class StringProcessor
{
public StringProcessor()
{
}
public String process(String name)
{
return name.toUpperCase();
}
}
1.2 发布步骤
1.准备一个目录作为web application的发布目录,我这里的这个目录叫jagiews,这个目录的全路径中最好不要有空格和中文。我的发布目录结构如下:
2.编译StringProcessor.java,把生成的StringProcessor.class置于: jagiewsWEB-INFclassescomjagiej2mews目录下。
3.在jagiewsWEB-INFlib 文件夹中置入以下axis服务器需要的jar文件 axis.jar,axis-ant.jar,commons-discovery.jar,commons-logging.jar,jaxrpc.jar,log4j-1.2.8.jar,saaj.jar ,wsdl4j.jar。这些文件可以在http://ws.apache.org/axis/下载。
4.在jagiewsWEB-INF目录下增加2个发布描述文件:
server-config.wsdd,web.xml。
#server-config.wsdd
<?xml version="1.0" encoding="UTF-8"?>
"http://xml.apache.org/axis/wsdd/"
xmlns:java=
"http://xml.apache.org/axis/wsdd/providers/java">
"adminPassword" value="admin"/>
"attachments.Directory"
value="C:Program Files
Apache Tomcat 4.0webapps
axisWEB-INFattachments"/>
"attachments.implementation"
value="org.apache.axis.
attachments.AttachmentsImpl"/>
"sendXsiTypes"
value="true"/>
"sendMultiRefs"
value="true"/>
"sendXMLDeclaration"
value="true"/>
"axis.sendMinimizedElements"
value="true"/>
"java:org.apache.axis.handlers.JWSHandler">
name="scope"
value="session"/>
"java:org.apache.axis.handlers.JWSHandler">
name="scope"
value="request"/>
name="extension"
value=".jwr"/>
"LocalResponder"
type="java:org.apache.axis.
transport.local.LocalResponder"/>
type="java:org.apache.axis.
handlers.http.URLMapper"/>
type="java:org.apache.axis.
providers.java.RPCProvider"/>
type="java:org.apache.axis.
handlers.SimpleAuthenticationHandler"/>
type="java:org.apache.axis.
providers.java.MsgProvider"/>
provider="java:MSG">
value="AdminService"/>
value="false"/>
value="org.apache.axis.utils.Admin"/>
http://xml.apache.org/axis/wsdd/
provider="java:RPC">
value="getVersion"/>
value="org.apache.axis.Version"/>
<!-- your service begin-->
provider="java:RPC">
value="process"/>
value="com.jagie.j2me.
ws.StringProcessor"/>
<!-- your service end -->
"java:org.apache.axis.handlers.
http.HTTPAuthHandler"/>
# web.xml
<?xml version="1.0"
encoding="ISO-8859-1"?>
br />PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com
/j2ee/dtds/web-app_2.2.dtd">
Apache-Axis
AxisServlet
Apache-Axis
Servlet
org.apache.axis.transport.http.AxisServlet
AdminServlet
Axis Admin Servlet
org.apache.axis.transport.http.AdminServlet
100
SOAPMonitorService
SOAPMonitorService
org.apache.axis.monitor.SOAPMonitorService
SOAPMonitorPort
5001
100
AxisServlet
/servlet/AxisServlet
AxisServlet
*.jws
AxisServlet
/services/*
SOAPMonitorService
/SOAPMonitor
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-127004/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10294527/viewspace-127004/