我對我的肥皂服務(wcf)有疑問 我實作了我的 wcf 服務并且所有函式在編譯時都正確實作了我沒有任何編譯時錯誤但是當我運行我的代碼時我收到了這個錯誤訊息
無法加載合約“test.ICore”的端點配置部分,因為找到該合約的多個端點配置。請注明首選端點配置
我認為在肥皂服務中,我們需要對 web.config 檔案進行一些更改,另一點是我的專案有多個肥皂服務。可能會導致問題嗎?
我該如何解決這個問題?太感謝了
uj5u.com熱心網友回復:
我認為您的問題是因為您的 web.config 檔案中有一個具有相同地址的多個端點
<binding name="TestSoap">
<security mode="Transport" />
</binding>
<binding name="TestSoap" />
<endpoint address="http://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="Soap" contract="TestSoap.ICore"
name="TestSoap" />
<endpoint address="https://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="TestSoap"
contract="TestSoap.ICore" name="TestSoap" />
您可以將此示例用于您的代碼。
我希望你能解決你的問題
uj5u.com熱心網友回復:
一般來說,一個介面契約可以被多個端點支持,但系結和地址可能會有所不同,例如:
服務器端:
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint address="secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
客戶端:
<client>
<endpoint name="basic"
address="http://localhost/servicemodelsamples/service.svc"
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint name="secure"
address="http://localhost/servicemodelsamples/service.svc/secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</client>
在通話中:
CalculatorClient client = new CalculatorClient("basic");
Console.WriteLine("Communicate with basic endpoint.");
client = new CalculatorClient("secure");
Console.WriteLine("Communicate with secure endpoint.");
如果有任何問題,請隨時與我聯系。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/526419.html
標籤:wcf
上一篇:分析和過濾資料框中的調查回應
