當前位置:首頁 » 編程語言 » wcfjava調用

wcfjava調用

發布時間: 2023-03-03 04:58:37

㈠ 如何調用帶參數的WCF方法

[OperationContract(Name="sayHelloJson")]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "sayHello", BodyStyle = WebMessageBodyStyle.Wrapped)]
String sayHello();
[OperationContract(Name = "SendMessageJson")]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "SendMessage/{Message}", BodyStyle = WebMessageBodyStyle.Wrapped)]
String SendMessage(String Message);
比如說第一個不帶參數的:http://localhost:8000/Service/Json/sayHello
那麼第二個帶參數的應該怎麼調用?(比如說參數是"abc")
我指的是在瀏覽器中或java的httpclient中,因為我准備在android上實現客戶端,所以.net的調用方式就不必講了。

你URITemplate已經設置了。Get方式。

我猜測一下調用的URL應該是: 網站URL/SendMessage/你好

另外建議你使用REST WCF自帶的一個幫助頁面,裡面會給出更精確的調用示例。

㈡ silverlight調用java webservice 錯誤,跨域文件clientaccesspolicy.xml已經放入到../webapps/ROOT下,如

這是跨域訪問數據造成的,你肯定是讓SL去訪問別的服務端數據了。解決辦法是必須在服務端放置跨域策略文件:
在WCF項目根目錄下添加clientaccesspolicy.xml文件,內容如下:
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

㈢ 怎麼用cxf的wsdl2java解析wcf生成的wsdl

1、下載apache-cxf-2.6.2在環境變數中配置CXF_HOME ,在PATH中加入%CXF_HOME%\bin 2、輸入cmd 進入控制窗口,輸入wsdl2java看是否配置成功
3、參考它的文檔看這個工具的具體參數的用法
wsdl2java用法:
wsdl2java -p com -d src -all aa.wsdl
-p 指定其wsdl的命名空間,也就是要生成代碼的包名:
-d 指定要產生代碼所在目錄
-client 生成客戶端測試web service的代碼
-server 生成伺服器啟動web service的代碼
-impl 生成web service的實現代碼
-ant 生成build.xml文件
-all 生成所有開始端點代碼:types,service proxy,,service interface, server mainline, client mainline, implementation object, and an Ant build.xml file.
詳細用法見:http://cwiki.apache.org/CXF20DOC/wsdl-to-java.html

熱點內容
phpfile亂碼 發布:2025-07-16 03:57:54 瀏覽:93
手機存儲空間擴容 發布:2025-07-16 03:52:07 瀏覽:861
小米4清除緩存 發布:2025-07-16 03:03:17 瀏覽:563
如何緩解壓力英語作文 發布:2025-07-16 03:03:15 瀏覽:15
手機視頻怎麼緩存 發布:2025-07-16 02:59:05 瀏覽:933
安卓手機設備在哪裡找 發布:2025-07-16 02:49:28 瀏覽:357
php建立數組 發布:2025-07-16 02:34:30 瀏覽:284
oracle存儲過程同步 發布:2025-07-16 02:29:18 瀏覽:941
歐諾s買哪個配置的好 發布:2025-07-16 02:26:22 瀏覽:559
熱點可以建立ftp嗎 發布:2025-07-16 02:26:21 瀏覽:304