标签:
java jdk:jdk1.5.0_17
下载网址:http://pan.baidu.com/s/1gdmAkgV
tomcat 6.0
下载地址:http://tomcat.apache.org/download-60.cgi
Axis1.3(注意现在已经版本已经是Axis2,而我们这里使用的是Axis1.x), Axis1.x运行环境要求低于jdk1.6(不包含jdk1.6),tomcat版本低于6.0(包含6.0):
下载地址:http://pan.baidu.com/s/1gdmAkgV
有了这些文件,还不够,我们还需要下载activation.jar mail.jar soap.jar xerces.jar(下载地址:http://pan.baidu.com/s/1gdmAkgV)四个包并且加入到用户库中
环境参数配置:
AXIS_LIB=D:\java\apache-tomcat-6.0.44\webapps\axis\WEB-INF\lib
AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;
CATALINA_HOME=D:\java\apache-tomcat-6.0.44
CLASS_PATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\lib\servlet-api.jar;%TOMCAT_HOME%/lib/soap.jar;%TOMCAT_HOME%/lib/mail.jar;%TOMCAT_HOME%/lib/activation.jar;%TOMCAT_HOME%/lib/xerces.jar;%AXISCLASSPATH%;
JAVA_HOME=D:\java\jdk1.5.0_17
Path在前边插入%JAVA_HOME%\bin;
1,)将下载的axis1.3解压,把里边的webapps下的文件夹axis,拷贝到tomcat6.0的webapps文件夹下。
2,)启动tomcat6.0,如果你还未安装tomcat6.0,需要进入目录:D:\java\apache-tomcat-6.0.44\bin
在cmd下,进入该目录,输入serivce.bat install进行tomcat6.0安装,安装完成后,找到D:\java\apache-tomcat-6.0.44\bin\tomcat6w.exe双击,在弹出界面中点击start按钮,等待tomcat运行起来后;
3,)访问网址:http://localhost:8080/axis
如果界面显示如下:
如果界面显示如上图,说明axis1.3已经发布成功。
4,)打开文本创建类,写一个这样的java类:
1 package com.group.webservices; 2 3 public class WebServiceTest { 4 /** 5 * 接口 6 * */ 7 public String validate(String name){ 8 String message=""; 9 message+= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; 10 message+= "<root>"; 11 12 if(name!=null&&name.trim().length()>0){ 13 message+= "<resultCode>1056</resultCode>"; 14 message+= "<resultMsg>解析成功</resultMsg>"; 15 }else{ 16 message+= "<resultCode>1050</resultCode>"; 17 message+= "<resultMsg>非法</resultMsg>"; 18 } 19 20 message+= "</root>"; 21 22 return message; 23 } 24 }
5,)在cmd中编译WebServiceTest.java,输入javac WebServiceTest.java回车,会在WebServiceTest.java目录下编译出一个WebServiceTest.class文件。
6,)将文件WebServiceTest.class拷贝,到目录D:\java\apache-tomcat-6.0.44\webapps\axis\WEB-INF\classes\com\group\webservices目录下(注意:D:\java\apache-tomcat-6.0.44\webapps\axis\WEB-INF\classes\的目录就是WebServiceTest.java的命名空间地址)
7,)在D:\java\apache-tomcat-6.0.44\webapps\axis\WEB-INF\下新建文件deploy.wsdd
文件内容:
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="TestService" provider="java:RPC"> <parameter name="className" value="com.group.webservices.WebServiceTest" /> <parameter name="allowedMethods" value="validate" /> </service> </deployment>
8,)在cmd中发布webservice命令:
java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient deploy.wsdd
你会发现目录下多了一个server-config.wsdd文件,这就是AXIS的配置文件,以后所有的服务发布描述都会在里面找到。(当然,你可以直接修改它,不用再写deploy.wsdd)然后打开浏览器http://localhost:8080/axis/servlet/AxisServlet,你就会看到你的服务已发布
9,)点击发布服务,就可以看到url变动为:
http://localhost:8080/axis/services/TestService?wsdl
内容显示为:
1 <wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/services/TestService" xmlns:intf="http://localhost:8080/axis/services/TestService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost:8080/axis/services/TestService"> 2 <!-- 3 WSDL created by Apache Axis version: 1.3 4 Built on Oct 05, 2005 (05:23:37 EDT) 5 --> 6 <wsdl:message name="validateRequest"> 7 <wsdl:part name="in0" type="soapenc:string"/> 8 </wsdl:message> 9 <wsdl:message name="validateResponse"> 10 <wsdl:part name="validateReturn" type="soapenc:string"/> 11 </wsdl:message> 12 <wsdl:portType name="WebServiceTest"> 13 <wsdl:operation name="validate" parameterOrder="in0"> 14 <wsdl:input message="impl:validateRequest" name="validateRequest"/> 15 <wsdl:output message="impl:validateResponse" name="validateResponse"/> 16 </wsdl:operation> 17 </wsdl:portType> 18 <wsdl:binding name="TestServiceSoapBinding" type="impl:WebServiceTest"> 19 <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 20 <wsdl:operation name="validate"> 21 <wsdlsoap:operation soapAction=""/> 22 <wsdl:input name="validateRequest"> 23 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservices.group.com" use="encoded"/> 24 </wsdl:input> 25 <wsdl:output name="validateResponse"> 26 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/TestService" use="encoded"/> 27 </wsdl:output> 28 </wsdl:operation> 29 </wsdl:binding> 30 <wsdl:service name="WebServiceTestService"> 31 <wsdl:port binding="impl:TestServiceSoapBinding" name="TestService"> 32 <wsdlsoap:address location="http://localhost:8080/axis/services/TestService"/> 33 </wsdl:port> 34 </wsdl:service> 35 </wsdl:definitions>
10,)使用c#调用该服务:
将文件拷贝到新建的c#工程下:
到此本已结束,多谢。
参考文章:
http://blog.csdn.net/zhangzhaokun/article/details/4582977
http://blog.163.com/xiaohui_1123@126/blog/static/398052402010614114245570/
http://wenku.baidu.com/link?url=ZS_A2cHKQthibUg5vdu1jqu5Mhh0__HGmB9-OHhTPQJ48kIWngSRr7XVhpJqGIyQ94HKKw1abOXataBJXiCHzZabjVRfKhfcAVoRaI1nEhC
http://blog.csdn.net/hubin1989/article/details/40825407
http://www.cnblogs.com/draem0507/archive/2012/09/13/2682720.html
http://blog.sina.com.cn/s/blog_752ca76a01018275.html
Tomcat6.0+Jdk1.5+Axis1.3搭建java webservice环境,并使用c#调用该服务。
标签:
原文地址:http://www.cnblogs.com/yy3b2007com/p/4934847.html