WCF 服务保留 tempUri 命名空间

WCF service keeps tempUri namespace

所以我需要为遗留客户端创建一些 WCF 服务。

问题是,在从 wdsl 文件生成合同后,我收到反序列化错误,因为该服务需要 http://tempuri.org/ 命名空间,即使如此,正确的命名空间也在合同中。

这里是服务的配置:

    <services>
        <service name="SystemNotificationHandling.Services.NotificationHandling">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="INotificationHandlingBinding"/>
        </service>
    </services>

    <bindings>
        <basicHttpBinding>
            <binding name="secureHttpBinding">
                <security mode="Transport">
                    <transport clientCredentialType="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

这是合同:

    [ServiceContract]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.8.3928.0")]
    [System.Web.Services.WebServiceBindingAttribute(Name="NotificationHandlingBinding", Namespace="http://xx.com/fake/1.0")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(ResponseMessage))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Header))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(NotificationRequestMessage))]
    public interface INotificationHandlingBinding 
    {
        
        [OperationContract]
        [System.Web.Services.WebMethodAttribute()]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://xx.com/fake/1.0/notifyEvent", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
        [return: System.Xml.Serialization.XmlElementAttribute("NotifyEventResponse", Namespace="http://xx.com/fake/1.0")]
         NotifyEventResponse notifyEvent([System.Xml.Serialization.XmlElementAttribute(Namespace="http://xx.com/fake/1.0")] NotifyEventRequest NotifyEventRequest);
        
    }

感谢您的帮助。

原来是合约生成有问题。我们通过 svcutil 再次生成合同,这次它向 OperationContract 属性和 ServiceContract 属性添加了命名空间。

谢谢蓝黄,你的评论有点指引我正确的方向。