Web Service之Axis起步

(1)配置axis,需要下载3个jar文件:activation.jar、mail.jar和xmlsec.jar。

(2)部署HelloWorld.jws文件(内容如下),提示“java.lang.RuntimeException: No compiler found in your classpath! (you may need to add 'tools.jar')”,将tools.jar和dt.jar文件从jdk拷贝至Tomcat 5.5/common/lib,解决。

public class HelloWorld  {
    
public String sayHello(String name)
{
        
return "axis say hello:" +
 name;
    }

}

(3)使用tcp monitor观察soap消息交换情况。 

F:/Apache Software Foundation/Tomcat 5.5/webapps/axis>java org.apache.axis.utils
.tcpmon 8081 localhost 8080

request和response消息如下:


==============
Listen Port: 8081
Target Host: localhost
Target Port: 8080
==== Request ====
POST /axis/HelloWorld.jws HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost:8081
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 445

<? xml version="1.0" encoding="UTF-8" ?>    
   
< soapenv:Envelope  xmlns:soapenv ="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd ="http://www.w3.org/2001/XMLSchema"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" >       
      
< soapenv:Body >          
         
< sayHello  soapenv:encodingStyle ="http://schemas.xmlsoap.org/soap/encoding/" >             
            
< param1  xsi:type ="xsd:string" > sun </ param1 >          
         
</ sayHello >       
      
</ soapenv:Body >    
   
</ soapenv:Envelope > ==== Response ====
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=9BFB75F7ADD1D9475DE9CEA3EB8724E9; Path=/axis
Content-Type: text/xml;charset=utf-8
Date: Sat, 06 Jan 2007 13:33:04 GMT
Connection: close

<? xml version="1.0" encoding="utf-8" ?>
   
< soapenv:Envelope  xmlns:soapenv ="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd ="http://www.w3.org/2001/XMLSchema"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" >
      
< soapenv:Body >
         
< sayHelloResponse  soapenv:encodingStyle ="http://schemas.xmlsoap.org/soap/encoding/" >
            
< sayHelloReturn  xsi:type ="xsd:string" > axis say hello:sun </ sayHelloReturn >
         
</ sayHelloResponse >
      
</ soapenv:Body >
   
</ soapenv:Envelope >
==============

(4)使用wsdd(Web Service Deployment Descriptor,Web服务部署描述语言)部署服务,主要有两点:

a. 修改axis自带的“server-config.wsdd”文件,添加自定义的服务。

b.添加axis自带的web.xml文件。

这样,访问http://localhost:8080/test/services

就可以看到自己的服务了。

详细配置可参考:http://www.cnblogs.com/bjzhanghao/archive/2004/10/09/50216.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值