none
OnPremise WCF + Azure Servie Bus + Silverlight client. The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize paramete

    問題

  • Hi I am getting below Error .

    Im using OnPremise WCF + Azure Servie Bus + Silverlight client.

    We are using WS2007HttpRelayBinding.

    When my Sliverlight client is trying to fetch the huge data, i'm getting below error.

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameterhttp://it.es.sdsd.services/2011/06/v1.0:GetServiceIssueRisksResult. The InnerException message was 'There was an error deserializing the object of type System.Collections.ObjectModel.ObservableCollection`1[[XYZ.ES.sdsdvNext.SilverlightUX.sdsdCoreProxy.ServiceIssueRisk, XYZ.ES.vNext.SilverlightUX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. Unexpected end of file while parsing Name has occurred. Line 1, position 16385.'.  Please see InnerException for more details. 
    Inner Exception : System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type System.Collections.ObjectModel.ObservableCollection`1[[XYZ.ES.xyzvNext.SilverlightUX.xyzCoreProxy.ServiceIssueRisk, XYZ.ES.xyzvNext.SilverlightUX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. Unexpected end of file while parsing Name has occurred. Line 1, position 16385. ---> System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 1, position 16385.

    But if my WCF service and Silverlight hosted server are on premise (withought Azure service bus end point), then i dont see any problem while fetching the same data.

    2012年3月3日 上午 03:39

解答

所有回覆

  • How large is the message you are trying to send over the service bus ?

    Messages going over the services bus can only be of a maximum of 256 KB, including the message headers. It notice it writes "Unexpected end of file while parsing Name has occured". So perhaps your message is too large and it's getting truncated, so it can not be deserialized back at the other side ?

    If your messages are too large, you either have to chop them up into multiple messages and transfer it that way. Or the preferred solution would be to store your message in blob storage and send a message over the write with the reference of your blob reference. Then again if you are using 2 on-premise solutions, it might incur quite some latency to get to blob storage from on-premise, so the first solution might be better.

    Be nice to nerds ... Chances are you'll end up working for one!



    2012年3月5日 上午 07:11
  • Silverlight doesn't support WS2007HttpRelayBinding. It doesn't even support BasicHttpRelayBinding. However, you can use BasicHttpRelayBinding on the service side, and turn off ACS, so it will have the same behavior as BasicHttpBinding. On the client side, you can just use a BasicHttpBinding to access the service.
    2012年3月5日 上午 09:42
  • Hi Thanks for your reply.

    I have tried with basicHttpRelaybinding  but i was getting the same error.

    this error is not happening for every method, it is only coming for some methods in the service, where we were using entity frame work to get the data .

    2012年3月6日 上午 09:36
  • Hi,

    Could you add a message inspector for Silverlight app?

    http://msdn.microsoft.com/en-us/library/aa717047.aspx

    In this way you're able to see what message is returned from Service Bus. By comparing it with the one returned in on-premises scenario you can see what the problem is. If possible you can also use message inspector to fix the problem by modifying the returned message before processing.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年3月8日 上午 07:35
  • Hi Allen ,

    Thanks for the inputs you provided .

    I Cheked the responses on both on premise and servcieBus response.

    On Premise , we weere getting complete response but in the case of serviceBus Endpoints , the xml data is being truncated of some point.

    OnPremise Response size and type of data ;

    -------------------------------------------

    HTTP/1.1 200 OK

    Content-Length: 96099

    Content-Type: application/soap+msbin1

    Server:sdfdf-IIS/7.5

    X-Powered-By: ASP.NET

    Cloud Servcie bus Response size and type of data  :

    --------------------------------------

    HTTP/1.1 200 OK

    Content-Type: application/soap+xml; charset=utf-8

    Server: fsdfsdf-HTTPAPI/2.0

    Content-Length: 16384

    We are using entityfaramework to process the  data.

    And this issue is not happening for all the service Methods.It is only happening for those methods like mentioned below,

     public TestObject GetTestDetails(Int32 Id)

            {

                using (var ctx = ServiceUtility.Context)

                {

                    var result = (from s in

                                     ctx.Sgps.Include("Table1")

                                     .Include("Table2")

                                     .Include("Table2")                                        

                                     .Include("Table3. Table4")

                                  where s.Id == Id

                                  select s).SingleOrDefault();

                    return (result);

                }

            }

    Whenever the client call is on methods having .include() multiple tables,We wete getting this Issue.

    Can we do anything on this particular methods. Or Please suggest me any other solution to resolve this issue.

    Thanks !

    2012年3月9日 上午 05:41
  • Hi,

    Thanks for the information. So it turns out the response from Service bus is turncated to 16k. Could you add a server side Message Inspector to make sure it's not your WCF service that turncated the message (look at BeforeSendReply method)? The below sample demonstrates how to add it as well as providing a sample using webHttpRelayBinding to expose data:

    http://code.msdn.microsoft.com/windowsazure/CSAzureServiceBusWCFDS-d69e2ae0

    You can also try whether webHttpRelayBinding works by leveraging above sample. To add custom query in WCF Data Services, you can refer to:

    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/12/01/way-to-expose-custom-method-in-an-entity-class-from-wcf-data-service.aspx

    The next test I would do is to expose a simple WCF method to return a string that is >16k. What's the result if you do so? Is the response still turncated at client? If both the webHttpRelayBinding and this simple test turncates at 16k we can conclude the size of the response is the cause and then need to figure out what turncates it.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    2012年3月9日 上午 08:07