WCF Soap服务反序列化失败(遇到无法识别的元素)

时间:2014-01-08 16:43:40

标签: wcf web-services soap

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

<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)写的客户端代理。 有没有人有想法解决这个问题?

1 个答案:

答案 0 :(得分:0)

但工作范围看起来很相似:怎么样?

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

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

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