我目前使用Mono for Android開發移動應用程序。我一直試圖通過添加一個Web引用來使用WCF Web服務,但似乎無法通過這種方式進行調用。我現在正在考慮硬着頭皮重寫Java代碼,而我並不擅長使用C#。適用於Android或Java和WCF的Mono
我有2個問題:
- 如何使用消費單爲Android一個WCF web服務。
如果我用java我怎麼會叫,看起來像下面的一個方法:
[OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/MyMethod", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] void MyMethod(CustomObjectFromDataContract c_Object);
當我打這個電話,我得到一個消息,說未處理的異常System.Net。引發WebException:。當我進入代碼時,我看到錯誤發生在您撥打電話時
[System.Web.Services.Protocols.SoapDocumentMethodAttribute ("http://tempuri.org/IMyService/MyMethod", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void MyMethod([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] CustomObjectFromDataContract c_Object) {
this.Invoke("MyMethod", new object[] {
c_Object});
}
invoke是拋出異常的那個。
「我似乎無法按照這種方式打電話」 - 您可以詳細說明這一部分嗎? – millimoose 2012-02-07 00:20:00
請包括異常消息和堆棧跟蹤 - 這將幫助我們幫助您... – 2012-02-07 08:28:12