【问题标题】:Wcf Backward compatibility issue - missing namespace on method parameterWcf 向后兼容性问题 - 方法参数上缺少命名空间
【发布时间】:2012-04-02 19:32:19
【问题描述】:

我们在 Windows 服务中托管我们的 WCF Web 服务。我们正在使用 basicHttpBinding。我们需要保持与 Soap 1.1 Web 服务的向后兼容性。我们的问题是 web 方法参数中元素 EPTalkMessage 上缺少命名空间。我搜索了很多,但没有找到将命名空间添加到此元素的方法。

旧网络服务的肥皂是:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://aaa.sk/EPTalk/IssueDocument</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<IssueDocument xmlns="http://aaa.sk/EPTalk">
  <EPTalkMessage xmlns="http://aaa.sk/EPTalk/ToSignInput" />
</IssueDocument>
</s:Body>
</s:Envelope>

新生成的肥皂是:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://aaa.sk/EPTalk/IssueDocument</Action>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <IssueDocument xmlns="http://aaa.sk/EPTalk">
      <EPTalkMessage />
    </IssueDocument >
  </s:Body>
</s:Envelope>

服务签名如下:

[ServiceContract (Namespace = "http://aaa.sk/EPTalk")]
[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document)]
public interface IRegistryInputWebService
{
    [OperationContract(Action = "http://aaa.sk/EPTalk/IssueDocument")]
    RegistryServiceResult IssueDocument([MessageParameter(Name = "EPTalkMessage")]
        UpvsPortalEmulator.ToSignInput.EPTalkMessage message);
}

绑定:

BasicHttpBinding
{                   
 MaxReceivedMessageSize = 1024 * 1024 * 10,
 MaxBufferSize = 1024 * 1024 * 10,
 ReaderQuotas =
              {
                MaxArrayLength = 1024 * 1024 * 10,
                MaxStringContentLength = 1024 * 1024 * 10
               },
 MessageEncoding = WSMessageEncoding.Text,
 Security = new BasicHttpSecurity
                {
                 Mode = BasicHttpSecurityMode.None
                 }
 };

已编辑:添加了 EPTalkMessage 定义。

 [XmlType, XmlRoot (ElementName = "EPTalkMessage", Namespace = Declarations.SchemaVersion, IsNullable = false), Serializable]
    public class EPTalkMessage
{
}

非常感谢您的帮助

【问题讨论】:

    标签: wcf soap basichttpbinding


    【解决方案1】:

    搜索了一段时间后,我用 MessageContracts 解决了这个问题。

    【讨论】:

      最近更新 更多