WCF: The deserializer has no knowledge of any type that maps to this name

i have a problem with WCF. I have this Contract:

[ServiceContract(Namespace = "http://www.aibis.de/webservices/{...}")]
public interface ISkaiService : IService
{

    [OperationContract(Name = "getErrorMessages")]
    GetErrorMessagesResponse GetErrorMessages(GetErrorMessagesRequest request);
}

This Responseclass:

[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; }
}

Now if i get a Response from this Function and deserialize it. The Programm calls a SerializationException "The Element "http://www.aibis.de/webservices/{...}:return"" contains Data of a Type which is associated to the name "http://response.data.{...}.webservices.aibis.de/xsd:ErrorCodeResponseData". The deserializer has no knowledge of any type that maps to this name...

This Exception also says that i could use the KnownType Attribute. I've tried it but it doesn't work. I tried also on the Servicecontract itself via :

[ServiceKnownType(typeof(ErrorCodeResponseData))]

I think there must be something wrong in my Code itself that the serializer cant find the Type.

Here is the Response as XML,that i get:

<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>

Note: I replaced some Url's with {...}

链接地址: http://www.djcxy.com/p/93558.html

上一篇: Java中的双重比较技巧

下一篇: WCF:反序列化程序不知道映射到此名称的任何类型