调用web服务出错,"该合约的多个端点配置或者“听无止境”

本文关键字:配置 端点 或者 听无止境 无止境 出错 服务 web quot 调用 | 更新日期: 2023-09-27 18:18:12

我只是有一个问题,它在这个线程中解决了添加web服务添加webservice

错误

现在我在调用它的方法

时遇到了一个问题

这是我的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(本地)上运行service,并通过删除第二个端点它刚刚工作!所以谁能帮我把这个工作http://service.proapp.ir/service/sedardIP.asmx plz??

调用web服务出错,"该合约的多个端点配置或者“听无止境”

您需要使用web参考的原因是什么?服务引用是更新的、更新的做事方式,但如果你出于某种原因需要使用web引用,那也没关系。

如果您使用服务引用路由,您可以指定您希望使用的端点,例如:

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

在设置服务引用之后,它可能会有一个新名称,但是您只需将新名称替换为sedardIPSoap12。