webservice发送字符串
生活随笔
收集整理的這篇文章主要介紹了
webservice发送字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
假設只是發送一個字符串client,這是很easy,只需要輸入xfire包,編寫接口,編寫的實現方法。變化。
假設你要傳輸的數組或自定義類。到用于接口準備的需要agexis文件。更復雜。
嘗試傳輸這些假設沒有成功。在發送成功的字符串,能寫自己的xml文件。讓client接受并解析。
接口類示范例如以下
package com.service;
public interface NewsInterface {public String GetNews(int start_page,int end_page);
}
實現方法
package com.service;public class NewsImpl implements NewsInterface{public String GetNews(int startPage, int endPage) {// TODO Auto-generated method stubString NewsXmlString="<total>20</total><detail><news><id>1</id><title>新聞1</title><date>2014-05-07</date><content>.....</content></news><news><id>2</id><title>新聞2</title><content>.....</content></news><news><title>新聞3</title><content>.....</content></news></detail>";return NewsXmlString;}}
改動services.xml文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xfire.codehaus.org/config/1.0"> <service> <name>GetNewsXml</name> <serviceClass>com.service.NewsInterface</serviceClass> <implementationClass> com.service.NewsImpl </implementationClass> <style>wrapped</style> <use>literal</use> <scope>application</scope> </service> </beans>
轉載于:https://www.cnblogs.com/mfrbuaa/p/4600967.html
總結
以上是生活随笔為你收集整理的webservice发送字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux UserSpace Back
- 下一篇: 宝骏车多少钱啊?