WCF:反序列化程序不知道映射到此名称的任何类型
我遇到了WCF的问题。 我有这个合同:
[ServiceContract(Namespace = "http://www.aibis.de/webservices/{...}")]
public interface ISkaiService : IService
{
[OperationContract(Name = "getErrorMessages")]
GetErrorMessagesResponse GetErrorMessages(GetErrorMessagesRequest request);
}
这个响应类:
[DataContract(Namespace = "http://www.aibis.de/webservices/{...}", Name = "getErrorMessagesResponse")]
public class GetErrorMessagesResponse
{
[DataMember(Order= 0, Name = "return")]
public ErrorCodeResponseData @Return { get; set; }
[DataContract(Namespace = "http://response.data.{...}.webservices.aibis.de/xsd")]
public class ErrorCodeResponseData : BasicResponseData
{
[DataMember(Name = "errorCodeMappings")]
public ErrorCodeMapping[] ErrorCodeMappings { get; set; }
}
[DataContract(Namespace = "http://data.{...}.webservices.aibis.de/xsd", Name = "errorCodeMapping")]
public class ErrorCodeMapping
{
[DataMember(Order = 0, Name = "code")]
public int Code { get; set; }
[DataMember(Order = 1, Name = "description")]
public string Description { get; set; }
}
}
[DataContract]
[KnownType(typeof(ErrorCodeResponseData))]
public class BasicResponseData
{
[DataMember(Name = "additionalParameter")]
public string AdditionalParameter { get; set; }
[DataMember(Name = "error")]
public bool Error { get; set; }
[DataMember(Name = "errorCode")]
public int ErrorCode { get; set; }
}
现在,如果我从这个函数得到一个响应并反序列化它。 Programm调用SerializationException“元素”http://www.aibis.de/webservices/{...}:return“”包含与名称“http://response.data”关联的类型数据。 {...}。webservices.aibis.de/xsd:ErrorCodeResponseData”。 反序列化器不知道映射到该名称的任何类型...
这个异常也说我可以使用KnownType属性。 我试过了,但它不起作用。 我也通过以下方式尝试了Servicecontract:
[ServiceKnownType(typeof运算(ErrorCodeResponseData))]
我认为我的代码本身必定有问题,序列化程序无法找到类型。
这里是作为XML的响应,我得到:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<soapenv:Body>
<ns:getErrorMessagesResponse xmlns:ns="http://www.aibis.de/webservices/{...}">
<ns:return xmlns:ax21="http://request.data.{...}.webservices.aibis.de/xsd" xmlns:ax22="http://data.{...}.webservices.aibis.de/xsd" xmlns:ax25="http://response.data.{...}.webservices.aibis.de/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax25:ErrorCodeResponseData">
<ax25:additionalParameter xsi:nil="true" />
<ax25:error>false</ax25:error>
<ax25:errorCode>0</ax25:errorCode>
<ax25:errorCodeMappings xsi:type="ax22:ErrorCodeMapping">
<ax22:code>0</ax22:code>
<ax22:description>OK</ax22:description>
</ax25:errorCodeMappings>
</ns:return>
</ns:getErrorMessagesResponse>
</soapenv:Body>
</soapenv:Envelope>
注意:我用{...}替换了某些网址
链接地址: http://www.djcxy.com/p/93557.html上一篇: WCF: The deserializer has no knowledge of any type that maps to this name