myeclipse构建webservice

http://apps.hi.baidu.com/share/detail/11053367

 

上面添加的第4步,在myelipse8.5好像不能成功不知道怎么回事,直接在浏览器输入网址:

 

http://192.168.13.112:8080/MyWebService/services/

 

得到如下结果:

---------------------------------------------------------------------------

 

Available Services:

  • MyFristWS [wsdl]





  • Generated by XFire ( http://xfire.codehaus.org )

 

---------------------------------------------------------------------------

 

关于客户端库文件的添加可以在上面新建的时候(4)就选择!

 

为了能够查看soap报文,在写客户端的时候添加了调试信息【http://xfire.codehaus.org/Logging】:

 

package com.myclient;

import java.net.URL;

import org.codehaus.xfire.client.Client;

public class GetService {
	   public static void main(String[] args) throws Exception
	   {
	       Client client = new Client(new URL("http://127.0.0.1:8080/MyWebService/services/MyFristWS?wsdl"));
	    // Tell XFire to cache a DOM document for the various in/out/fault flows
	       client.addInHandler(new org.codehaus.xfire.util.dom.DOMInHandler());
	       client.addOutHandler(new org.codehaus.xfire.util.dom.DOMOutHandler());
	       client.addFaultHandler(new org.codehaus.xfire.util.dom.DOMOutHandler());

	       // Add a logging handler to each flow
	       client.addInHandler(new org.codehaus.xfire.util.LoggingHandler());
	       client.addOutHandler(new org.codehaus.xfire.util.LoggingHandler());
	       client.addFaultHandler(new org.codehaus.xfire.util.LoggingHandler());
	       Object[] results = client.invoke("example", new Object[] {"hello"});
	       System.out.println((String) results[0]);
	   }
}
运行结果如下:
hello
2010-12-21 11:29:07 org.codehaus.xfire.util.LoggingHandler invoke
信息: <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns1:example xmlns:ns1="http://myserver.com">
<ns1:in0>hello</ns1:in0>
</ns1:example>
</soap:Body>
</soap:Envelope>

2010-12-21 11:29:07 org.codehaus.xfire.util.LoggingHandler invoke
信息: <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns1:exampleResponse xmlns:ns1="http://myserver.com">
<ns1:out>hello</ns1:out>
</ns1:exampleResponse>
</soap:Body>
</soap:Envelope>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值