原因是config节点中有多个endpoint相同节点,提示按名称指示首选的终结点,说明程序不知道选那个节点。

解决办法,实例化service服务对象时,通过name值指定创建它。

 

config文件部分

      <client>
            <endpoint address="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx"
                binding="basicHttpBinding" bindingConfiguration="WeatherWSSoap"
                contract="ServiceReference1.WeatherWSSoap" name="WeatherWSSoap" />
            <endpoint address="http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx"
                binding="customBinding" bindingConfiguration="WeatherWSSoap12"
                contract="ServiceReference1.WeatherWSSoap" name="WeatherWSSoap12" />
        </client>

ServiceReference1.WeatherWSSoapClient wwsc = new ServiceReference1.WeatherWSSoapClient("WeatherWSSoap");
string[] provinces = wwsc.getRegionProvince();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-09-10
  • 2021-11-16
  • 2021-10-29
相关资源
相似解决方案