【问题标题】:WCF Soap Service Deserialization failed (unrecognized element was encountered)WCF Soap 服务反序列化失败(遇到无法识别的元素)
【发布时间】:2014-01-08 16:43:40
【问题描述】:

我用 2 种方法构建了一个 WCF 自托管 WS(basichttp-binding)。然后创建一个 WSDL 并将其交付给客户。现在他们正在向服务发送 SOAP 请求,但我的方法之一(PostSendeplatz)每次都失败,参数为空。在跟踪中,我看到以下内容:

<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Verbose">
  <TraceIdentifier>http://msdn.microsoft.com/de-DE/library/System.Runtime.Serialization..aspx</TraceIdentifier>
  <Description>An unrecognized element was encountered in the XML during deserialization which was ignored.</Description>
  <AppDomain>RabbitServerTopSelf.vshost.exe</AppDomain>
  <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/StringTraceRecord">
    <Element>http://plantri.de:sendeplatz</Element>
  </ExtendedData>
</TraceRecord>

我在 DataContracts、ServiceContract 和 ServiceImplementation 中检查了我的命名空间:

[ServiceContract(Namespace = "http://plantri.de")]
public interface IRabbitImportService {
    [OperationContract]
    bool PostSendung(Sendung sendung, out string errorMsg);

    [OperationContract]
    bool PostSendeplatz(Sendeplatz sendePlatz, out string errorMsg);
}
...
[DataContract(Namespace = "http://plantri.de")]
public class Sendeplatz : RabbitIdBase { ...
...
[DataContract(Namespace = "http://plantri.de")]
public class Sendung : RabbitIdBase { ...
...
[ServiceBehavior(Namespace="http://plantri.de")]
public class RabbitImportService : Log4NetLogWriter, IRabbitImportService {
...
public bool PostSendung(Sendung sendung, out string errorMsg) {
... do something and return success
}

public bool PostSendeplatz(Sendeplatz sendePlatz, out string errorMsg) {
  errorMsg = String.Empty;

  if (sendePlatz == null) {
    Error("no Sendeplatz send!");
    return false;
  }
  ... never came until this point!!!!
}

这是未反序列化的肥皂信封的一部分(来自跟踪):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://192.168.40.64:8800/RabbitImportService</To>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://plantri.de/IRabbitImportService/PostSendeplatz</Action>
    </s:Header>
    <soapenv:Body>
        <PostSendeplatz xmlns="http://plantri.de">
            <sendeplatz>
                <Id>1258878</Id>
...

但工作信封看起来完全一样:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://192.168.40.64:8800/RabbitImportService</To>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://plantri.de/IRabbitImportService/PostSendung</Action>
    </s:Header>
    <soapenv:Body>
        <PostSendung xmlns="http://plantri.de">
            <sendung>
                <Id>564589</Id>
...

我没有机会更改由客户 (JAVA) 编写的客户端代理。 有没有人有解决问题的想法?

【问题讨论】:

    标签: wcf web-services soap


    【解决方案1】:

    但工作信封看起来完全一样:如何?

          <PostSendeplatz xmlns="http://plantri.de">
            <sendeplatz>
    
          <PostSendung xmlns="http://plantri.de">
            <sendung>
    

    我看到这些标签名称不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多