当前位置: 首页 >> 程序设计 >> Web Service之Axis起步
 

Web Service之Axis起步

作者:      来源:http://blog.csdn.net/nomad2     发表时间:2007-01-21     浏览次数:      字号:    

(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

责任编辑 webmaster

 
 
 
 
 
评论更多>>
 
 
 
发表
 
姓名: QQ:
性别: MSN:
E-mail: 主页:
评分: 1 2 3 4 5
评论内容:
验证码:
  
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表网友个人观点,与本网站立场无关。
  •