所以我需要為舊客戶端創建一些 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);
}
謝謝你的幫助。
uj5u.com熱心網友回復:
所以事實證明,合約生成是錯誤的。我們通過 svcutil 再次生成了合約,這次它為 OperationContract 屬性和 ServiceContract 屬性添加了命名空間。
謝謝 Lan Huang,你的評論有點為我指明了正確的方向。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/370107.html
