如何在c#Web应用程序中向外部托管的Web服务添加Web引用?

如何在c#Web应用程序中向外部托管的Web服务添加Web引用?

问题描述:

嘿程序员!!!



在向外部托管的asmx webservice添加Web引用时,我收到错误Value不能为null。

参数名称:discoveryError&mexError。并且添加参考按钮显示为禁用。请帮助我。

Hey programmers!!!

While adding a web reference to an externally hosted asmx webservice I am getting an error "Value cannot be null.
Parameter name: discoveryError & mexError". And the button "Add reference" appearing disabled. Kindly help me people.

I've found the solution.  And let me share the solution so that it can benefit others.
We have to change the web.config file of the project. Just add these tags in web.config file.

<system.net>
  <defaultProxy useDefaultCredentials="true">
  <proxy proxyaddress="http://direct.data.com/cmv/cmv.asmx"  bypassonlocal="True"/>
  </defaultProxy>
  </system.net>

And Then create the object of the service reference like this(in .aspx.cs file).

reference_Name.Service_NameSoapClient object_name =
 new reference_Name.Service_NameSoapClient();

And then call the web method like this.

object_name.method_name(parameter1,parameter2);

Here I've made the explanation generic by using reference_Name,Service_Name, object_name
These are not keywords :)


转到互联网属性 - >局域网设置 - >高级 - >在添加引用的pc中添加IP(不要使用代理地址)。问题已解决。
Goto internet properties --> LAN settings --> Advanced --> Add the IP to (do not use proxy for address) in pc where reference is added . Issue resolved.