开发者

WinPhone WCF: ErrorObject parsing / EndInvoke() Error

I'm programming a WindowsPhone App which is using a SOAP based WebService, with help of WCF. I've got the problem, that something with the parsing doesn't work like it should work. There is the generated class (Reference.cs), generated by visual studio on the basis of the wsdl description of the service. If I call a servicemethod and there is no error all is fine, request is send and I get an answere. But if something goes wrong, request is sent and server returns an error object. This object is named "ClientException" and specified by the wsdl file. The problem is now that the Code fails get the (error) return value and can not return the exception. Concrete base.EndInvoke() fails. This seems to be a winphone / silverlight problem, tested with a normal wcf client there are no problems with the service and/or parsing.

Here is some code to show what I mean:

Code from 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, result) fails with

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.<InvokeGetRes开发者_如何转开发ponseCallback>b__8(Object state2)
bei System.Threading.ThreadPool.WorkItem.doWork(Object o)
bei System.Threading.Timer.ring()

I hope I explained the problem detailed enought. Is there a solution to fix this problem?

Thanks for your time!


A quick glance at the error message shows it's a cast exception on the client side, so it's unhappy trying to deserialize the object on the client end.

I'm unable to see the wsdl but it looks like there is a mismatch between your server and client object definitions. Possibly you changed elements of the return message on the server but didn't refresh the client. This would also explain why it works in your test projects - you're getting the correct service reference data from them while your actual project has an old service definition.

Have you tried refreshing your WCF service information on the clent? (right-click on the service in the client project and click "Update")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜