簡體   English   中英

調用Web服務時出現錯誤,“該合同有多個端點配置”或“沒有端點監聽”

[英]Errors calling web service, “ more than one endpoint configuration for that contract” or “no endpoint listening”

我只是在添加Web服務時遇到問題, 在添加Web服務時此線程錯誤解決了該問題

現在我只是通過調用其方法有一個問題

這是我的app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="sedardIPSoap" />
        </basicHttpBinding>
        <customBinding>
            <binding name="sedardIPSoap12">
                <textMessageEncoding messageVersion="Soap12" />
                <httpTransport />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://service.proapp.ir/service/sedardIP.asmx"
            binding="basicHttpBinding" bindingConfiguration="sedardIPSoap"
            contract="sedardip_set.sedardIPSoap" name="sedardIPSoap" />
        <endpoint address="http://service.proapp.ir/service/sedardIP.asmx"
            binding="customBinding" bindingConfiguration="sedardIPSoap12"
            contract="sedardip_set.sedardIPSoap" name="sedardIPSoap12" />
    </client>
</system.serviceModel>

所以當我嘗試像這樣調用我的函數時

sedardip_set.sedardIPSoapClient nm = new sedardip_set.sedardIPSoapClient();
nm.set_ip("x1", "x2", "x3");

拋出這個異常

An endpoint configuration section for contract 'sedardip_set.sedardIPSoap' 
could not be loaded because more than one endpoint configuration for that 
contract was found. Please indicate the preferred endpoint configuration 
section by name.

所以我嘗試從app.config中刪除其中一個端點,之后它會引發此異常

There was no endpoint listening at http://service.proapp.ir/service/sedardIP.asmx 
that could accept the message. This is often caused by an incorrect address or 
SOAP action. See InnerException, if present, for more details.

內部異常

{"The remote server returned an error: (404) Not Found."}

我只是在我的Visual Studio(本地)上運行服務,並刪除了第二個端點即可使用! 所以任何人都可以幫助我在http://service.proapp.ir/service/sedardIP.asmx plz上進行此工作嗎?

您是否需要使用網絡參考的原因? 服務參考是更新的,更新的工作方式,但是如果出於某種原因需要使用網絡參考,那也很好。

如果您使用服務參考路線,則可以專門命名要使用的端點,例如:

sedardip_set.sedardIPSoapClient nm = new sedardip_set.sedardIPSoapClient("sedardIPSoap12");
nm.set_ip("x1", "x2", "x3");

設置服務引用后,它可能會有一個新名稱,但是您只需用新名稱代替sedardIPSoap12。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM