开发者

MVC Deserialization Error

Okay. This is my company's customer portal, it's an MVC 2 project. We have a back end SAP system that the portal draws data from. But it does not directly hit SAP, it sends an xml request to a VB app that gets the data and sends it back in an xml response. There is an interface IRequest that all the various requests implement examples would be CustomerNumberRequest, CompanyNameRequest, etc. These all implement the method ToXml which as the name suggests simply builds xml to send. All of the existing requests work fine. (Let me preface this by saying that I inherited this project and the guy who wrote it is no longer with us) I am now trying to send a request to get the Rep Groups from SAP. I basically copied one of the other requests verbatim, making the necessary tweaks to send the appropriate request. But it keeps failing with error messages that I don't understand:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:request. The InnerException message was 'The deserializer cannot load the type to deserialize because type 'XXXXX.CustomerPortal.Domain.RepGroupRequest' could not be found in assembly 'XXXXX.CustomerPortal.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Check that the type being serialized has the same contract as the type being deserialized and the开发者_StackOverflow same assembly is used.'. Please see InnerException for more details.

This error happens right at _communicationService.ProcessRequest(request); (shown below) It does not enter the ProcessRequest method it just tries to create a NetDataContractSerializer here:

public override XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes)
{
    return new NetDataContractSerializer();
}

and then it dies. These are the methods being called:

private void PopulateRepGroups()
{
    List<string> repGroups = new List<string>();
    RepGroupRequest request = new RepGroupRequest();
    foreach (RepGroup repGroup in _repService.GetRepGroups(request))
        repGroups.Add(repGroup.RepGroupName);
    ViewData["RepGroups"] = new SelectList(repGroups);
}


public List<RepGroup> GetRepGroups(RepGroupRequest request)
{
    string response = _communicationService.ProcessRequest(request);
    return RepGroupResponseFactory.GetRepGroupResponse(response);
}

Can anybody tell me what this error message is telling me? It says the type cannot be found but the type should be IRequest (that's what it says when the CreateSerializer is hit) which is used all over this. I'm clearly lost, please help!


Quoting your exception

Check that the type being serialized has the same contract as the type being deserialized and the same assembly is used

Check the version of the library on both ends that CustomerPortal.Domain.RepGroupRequest resides in to make sure they are the same version exactly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜