WebServices 访问 小结

1、使用JDK自带wsimport工具

wsimport -d ./bin -s ./src -p wei.peng.client http://localhost:8888/WEIPENG/HelloServices?wsdl  

在命令行输入上述命令之后,会根据WSDL生成系列相关的辅助类,编译Client端的调用、开发

相当的简单、明了

 

2、Xfire封装的API Client

很不错的,

package wei.peng.client.test;

import java.net.MalformedURLException;
import java.net.URL;

import org.codehaus.xfire.client.Client;


/**
 * 使用Xfire封装的Client API调用Web Services
 * @author WPeng
 * @time  2011-3-15 下午12:31:25
 * @email pengwei841221@126.com
 */
public class TestClient_3_XFire{

	public static void main(String[] args) {
		try {
			Client client = new Client(new URL("http://localhost:10000/XFire1/services/HelloService?wsdl"));
			Object[] results = client.invoke("hello", new Object[]{"wei.peng"});
			System.out.println(results[0]);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

 

3、可以在浏览器中使用URL直接访问

检查Web Service对不对

在浏览器地址栏输入:
http://localhost/axis/SayHello.jws?method=hello 即可访问方法hello,返回的是整个SOAP数据包。

简单对象访问协议(SOAP,全寫為Simple Object Access Protocol)是一種標準化的通訊規範,主要用于Web服务(web service)中。

<?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>
		<helloResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
			<helloReturn xsi:type="xsd:string">Hello, axis Ver1.4 talking to you.
			</helloReturn>
		</helloResponse>
	</soapenv:Body>
</soapenv:Envelope> 
 

 

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值