axis1.4 webservice java服务端配置

1.先下载axis-bin-1_4拿到所需要的jar包
我用的jar如下:
axis-ant.jar

axis.jar

commons-discovery-0.2.jar

commons-logging-1.0.4.jar

jaxrpc.jar

log4j-1.2.8.jar

saaj.jar

wsdl4j-1.5.1.jar
1.在eclipse中创建web项目


2.再把jar包COPY到lib目录下
3.在web.xml中加入以下代码:

<listener>
        <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
    </listener>
   
  <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>
    <servlet-name>SOAPMonitorService</servlet-name>
    <display-name>SOAPMonitorService</display-name>
    <servlet-class>
        org.apache.axis.monitor.SOAPMonitorService
    </servlet-class>
    <init-param>
      <param-name>SOAPMonitorPort</param-name>
      <param-value>5001</param-value>
    </init-param>
    <load-on-startup>100</load-on-startup>
  </servlet>

 

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>SOAPMonitorService</servlet-name>
    <url-pattern>/SOAPMonitor</url-pattern>
  </servlet-mapping>

4.创建服务端类

package server;
public class SayHello {
 public String getName(String name)
    {
        return "hello "+name;
    }
}

5.编写WebRoot\WEB-INF\deploy.wsdd文件

<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="SayHello" provider="java:RPC">
<parameter name="className" value="server.SayHello"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="request"/>
</service>
</deployment>

6.在tomcat中启动项目

7.

  打开cmd 进入 目录 :WEB-INF\

  输入部署命令(注意更改命令中服务的地址和端口)

  java -Djava.ext.dirs=lib org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services   deploy.wsdd

  若显示
  Processing file deploy.wsdd
  <Admin>Done processing</Admin>

  则表示发布服务成功

8.在浏览器中输入地址
   http://localhost:8080/axitDemo/services
   会显示你所发布的服务

And now... Some Services

点击  SayHello (wsdl)   便会显示其XML ,点右健,查看源文件,保存XML为WebRoot\WEB-INF\SayHello.xml

 

你可能感兴趣的:(webservice)