我編程的WindowsPhone應用程序正在使用基於SOAP的WebService,在WCF的幫助下。 我有這個問題,解析的東西不能像它應該工作。生成的類(Reference.cs)由Visual Studio根據服務的wsdl描述生成。如果我打電話給servicemethod並且沒有錯誤,一切正常,請求發送並且我得到一個回答。但是如果出現問題,則發送請求並且服務器返回一個錯誤對象。該對象被命名爲「ClientException」並由wsdl文件指定。現在的問題是,代碼無法獲得(錯誤)返回值,並且無法返回異常。具體base.EndInvoke()失敗。這似乎是一個winphone/silverlight問題,用普通的wcf客戶端進行測試,服務和/或解析沒有問題。WinPhone WCF:ErrorObject解析/ EndInvoke()錯誤
下面是一些代碼來說明我的意思:從Reference.cs
public IAsyncResult BegingetCubeState(AsyncCallback callback, object asyncState)
{
object[] _args = new object[0];
IAsyncResult _result = base.BeginInvoke("getCubeState", _args, callback, asyncState);
return _result;
}
public CubeState EndgetCubeState(IAsyncResult result)
{
object[] _args = new object[0];
Debugger.Break();
CubeState _result = ((CubeState)(base.EndInvoke("getCubeState", _args, result)));
return _result;
}
base.EndInvoke
代碼( 「getMaxCubeState」,_args,結果)失敗,
InvalidCastException
bei System.ServiceModel.Dispatcher.XmlSerializerObjectSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
bei System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlReader reader, Boolean verifyObjectName)
bei System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName)
bei System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
bei System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
bei System.ServiceModel.Dispatcher.XmlSerializerFaultFormatter.CreateFaultException(MessageFault messageFault, String action)
bei System.ServiceModel.Dispatcher.FaultFormatter.Deserialize(MessageFault messageFault, String action)
bei System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
bei System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
bei System.ServiceModel.ClientBase1.ChannelBase1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
bei WindowsPhoneStr.ServiceReferenceSoap.RemoteClient.RemoteClientChannel.EndgetCubeState(IAsyncResult result)
bei WindowsPhoneStr.ServiceReferenceSoap.RemoteClient.WindowsPhoneStr.ServiceReferenceSoap.IRemote.EndgetCubeState(IAsyncResult result)
bei WindowsPhoneStr.ServiceReferenceSoap.RemoteClient.OnEndgetCubeState(IAsyncResult result)
bei System.ServiceModel.ClientBase1.OnAsyncCallCompleted(IAsyncResult result)
bei System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
bei System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously, Exception exception)
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.CallComplete(Boolean completedSynchronously, Exception exception)
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishSend(IAsyncResult result, Boolean completedSynchronously)
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.SendCallback(IAsyncResult result)
bei System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
bei System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously, Exception exception)
bei System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.OnGetResponse(IAsyncResult result)
bei System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
bei System.Threading.ThreadPool.WorkItem.doWork(Object o)
bei System.Threading.Timer.ring()
我希望我詳細解釋了這個問題。有沒有解決這個問題的解決方案?
謝謝你的時間!
您可以發佈WSDL嗎?也許SL有一種類型不理解? – 2011-08-18 15:21:29
wsdl:http://pastebin.com/qRJPs3n1 wsdl界面:http://pastebin.com/2G2bJCsW – 2011-09-02 07:49:24