一、创建web项目
webservice是通过http/https协议访问,所以要创建web项目,这里按maven格式来创建web工程。
工程名称:test-axis1,这里使用axis1版本。
IUpayCsysTmallTxnLog.java webservice的接口
UpayCsysTmallTxnLog.java 接口的实现
UpayCsysTmallTxnLogReq.java接口的请求对象
UpayCsysTmallTxnLogResp.java接口返回对象
二、创建webservice服务端
2.1 选中工程test-axis1,右键 New->Other->Web Services->Web Service
2.2 点击【Next】按钮
Web service type下拉框选择:Bottom up java bean Web Service (自底向上的java bean Web服务)
点击Browse,输入框中输入刚才新建的接口实现类,这个类将作为web service的调用服务
2.3 点击【OK】,然后再Configuration栏里点击【Server runtime:tomcat……】
eclipse需要配置好web服务器,这里用的是tomcat所以选中输入框圈的那部分。
2.4 点击【OK】按钮,在弹出来的对话框里点击【Next】
2.5 按默认选择即可,点击【Next】
2.6 点击【Start server】按钮,测试web service服务端,如果没问题,点击【Next】按钮
2.7 按默认配置,一直点击【Next】
2.8 点击【Finish】按钮之后,如果不出问题的话,eclipse自动启动web service服务端,并弹出两个自带的浏览器,上面显示一些信息
eclipse的web service插件会帮生成很多东西,比如jar包,wsdd文件,wsdl文件等等其他配置信息,如左边圈子里的,都是自动生成的。
如web.xml,会自动写入很多配置信息:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<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>
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
</web-app>
2.9 打开test-axis1/src/main/webapp/wsdl/UpayCsysTmallTxnLog.wsdl配置文件,可以看到很多入参和出参的描述信息
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://axis1.webservice.plg.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://axis1.webservice.plg.com" xmlns:intf="http://axis1.webservice.plg.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://axis1.webservice.plg.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getUpayCsysTmallLog">
<complexType>
<sequence>
<element name="req" type="impl:UpayCsysTmallTxnLogReq"/>
<element name="version" type="xsd:string"/>
</sequence>
</complexType>
</element>
<complexType name="UpayCsysTmallTxnLogReq">
<sequence>
<element name="bussChl" nillable="true" type="xsd:string"/>
<element name="bussType" nillable="true" type="xsd:string"/>
<element name="crmActivityCode" nillable="true" type="xsd:string"/>
<element name="crmBipCode" nillable="true" type="xsd:string"/>
<element name="crmCnlType" nillable="true" type="xsd:string"/>
<element name="crmOprDt" nillable="true" type="xsd:string"/>
<element name="crmOprId" nillable="true" type="xsd:string"/>
<element name="crmOprTm" nillable="true" type="xsd:string"/>
<element name="crmOrgId" nillable="true" type="xsd:string"/>
<element name="crmRouteInfo" nillable="true" type="xsd:string"/>
<element name="crmRouteType" nillable="true" type="xsd:string"/>
<element name="crmRouteVal" nillable="true" type="xsd:string"/>
<element name="crmSessionId" nillable="true" type="xsd:string"/>
<element name="crmStartTm" nillable="true" type="xsd:string"/>
<element name="crmTransDt" nillable="true" type="xsd:string"/>
<element name="crmTransId" nillable="true" type="xsd:string"/>
<element name="crmTransTm" nillable="true" type="xsd:string"/>
<element name="crmTranshDt" nillable="true" type="xsd:string"/>
<element name="crmTranshId" nillable="true" type="xsd:string"/>
<element name="crmTranshTm" nillable="true" type="xsd:string"/>
<element name="intTransCode" nillable="true" type="xsd:string"/>
<element name="intTxnDate" nillable="true" type="xsd:string"/>
<element name="intTxnSeq" nillable="true" type="xsd:string"/>
<element name="intTxnTime" nillable="true" type="xsd:string"/>
<element name="payMode" nillable="true" type="xsd:string"/>
<element name="seqId" nillable="true" type="xsd:long"/>
<element name="settleDate" nillable="true" type="xsd:string"/>
<element name="tmallActivityCode" nillable="true" type="xsd:string"/>
<element name="tmallCnlType" nillable="true" type="xsd:string"/>
<element name="tmallOrgId" nillable="true" type="xsd:string"/>
<element name="tmallRouteInfo" nillable="true" type="xsd:string"/>
<element name="tmallTransDt" nillable="true" type="xsd:string"/>
<element name="tmallTransId" nillable="true" type="xsd:string"/>
<element name="tmallTransTm" nillable="true" type="xsd:string"/>
<element name="tmallTranshDt" nillable="true" type="xsd:string"/>
<element name="tmallTranshId" nillable="true" type="xsd:string"/>
<element name="tmallTranshTm" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<element name="getUpayCsysTmallLogResponse">
<complexType>
<sequence>
<element name="getUpayCsysTmallLogReturn" type="impl:UpayCsysTmallTxnLogResp"/>
</sequence>
</complexType>
</element>
<complexType name="UpayCsysTmallTxnLogResp">
<sequence>
<element name="bussChl" nillable="true" type="xsd:string"/>
<element name="bussType" nillable="true" type="xsd:string"/>
<element name="intTransCode" nillable="true" type="xsd:string"/>
<element name="intTxnDate" nillable="true" type="xsd:string"/>
<element name="intTxnSeq" nillable="true" type="xsd:string"/>
<element name="intTxnTime" nillable="true" type="xsd:string"/>
<element name="payMode" nillable="true" type="xsd:string"/>
<element name="seqId" nillable="true" type="xsd:long"/>
<element name="settleDate" nillable="true" type="xsd:string"/>
<element name="tmallActivityCode" nillable="true" type="xsd:string"/>
<element name="tmallOrgId" nillable="true" type="xsd:string"/>
<element name="tmallRouteInfo" nillable="true" type="xsd:string"/>
<element name="tmallTransDt" nillable="true" type="xsd:string"/>
<element name="tmallTransId" nillable="true" type="xsd:string"/>
<element name="tmallTransTm" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getUpayCsysTmallLogResponse">
<wsdl:part element="impl:getUpayCsysTmallLogResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getUpayCsysTmallLogRequest">
<wsdl:part element="impl:getUpayCsysTmallLog" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="UpayCsysTmallTxnLog">
<wsdl:operation name="getUpayCsysTmallLog">
<wsdl:input message="impl:getUpayCsysTmallLogRequest" name="getUpayCsysTmallLogRequest">
</wsdl:input>
<wsdl:output message="impl:getUpayCsysTmallLogResponse" name="getUpayCsysTmallLogResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UpayCsysTmallTxnLogSoapBinding" type="impl:UpayCsysTmallTxnLog">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUpayCsysTmallLog">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getUpayCsysTmallLogRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getUpayCsysTmallLogResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UpayCsysTmallTxnLogService">
<wsdl:port binding="impl:UpayCsysTmallTxnLogSoapBinding" name="UpayCsysTmallTxnLog">
<wsdlsoap:address location="http://localhost:8080/test-axis1/services/UpayCsysTmallTxnLog"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2.10 浏览器访问测试web service服务端发布情况
打开浏览器,访问http://localhost:8080/test-axis1/services/UpayCsysTmallTxnLog(注localhost改成web service服务端发布的IP地址)
说明web service发布成功。
还可以访问http://localhost:8080/test-axis1/services/UpayCsysTmallTxnLog?wsdl,查看webservice服务描述文件