调用 Web 服务时出错,“该合同的多个端点配置"或“无端点监听" [英] Errors calling web service, " more than one endpoint configuration for that contract" or "no endpoint listening"

查看:34
本文介绍了调用 Web 服务时出错,“该合同的多个端点配置"或“无端点监听"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在添加 webservice 时遇到问题,该问题已在此线程中解决添加网络服务时出错

i just had a problem adding webservice that its solved in this thread error on adding webservice

现在我只是在调用它的方法时遇到问题

now i just have a problem by calling its method

这是我的 app.config

this is my 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>

所以当我尝试像这样调用我的函数时

so when i try calling my function like this

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 中删除其中一个端点,之后它抛出此异常

so i tried deleting one of the endpoints from app.config, after that it throws this exception

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."}

我只是在我的视觉工作室(本地)上运行服务,并通过删除第二个端点它刚刚工作!所以任何人都可以帮助我在 http://service.proapp.ir/service/sedardIP.asmx plz??

i just run service on my visual studio (locally) and by deleting second endpoint its just worked ! so can anyone plz help me to get this working on http://service.proapp.ir/service/sedardIP.asmx plz??

推荐答案

您是否需要使用 Web 参考?服务引用是更新的、更新的处理方式,但如果您出于某种原因需要使用网络引用,那也没关系.

Is there a reason you need to use a web reference? A service reference is the updated, newer way of doing things, but if you need to use the web reference for some reason then that's fine too.

如果您使用服务引用路由,您可以专门命名您希望使用的端点,例如:

If you go the service reference route you can specifically name the endpoint you wish to use, for example:

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

设置服务引用后它可能有一个新名称,但您只需用新名称替换 sedardIPSoap12.

It may have a new name after setting up the service reference but you would just substitute the new name in place of the sedardIPSoap12.

这篇关于调用 Web 服务时出错,“该合同的多个端点配置"或“无端点监听"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆