[英]Client Program unable to connect with Web server
I have a web service application http://localhost:49804/Service1.asmx and I'm able to call methods using a C# application successfully. 我有一个Web服务应用程序http:// localhost:49804 / Service1.asmx,并且能够成功使用C#应用程序调用方法。
Later I have hosted the same Web service on IIS ( http://localhost/MyFirstWebService/Service1.asmx ) and I'm able to use with Web page(http put/get). 后来,我在IIS上托管了相同的Web服务( http://localhost/MyFirstWebService/Service1.asmx ),并且可以与Web页面一起使用(http put / get)。
Now I have updated web service reference to http://localhost/MyFirstWebService/Service1.asmx in my C# application. 现在,我已经在C#应用程序中将Web服务引用更新为http://localhost/MyFirstWebService/Service1.asmx 。 Now If I call same method I'm getting Exception:
现在,如果我调用相同的方法,则会出现异常:
An endpoint configuration section for contract 'ServiceReference1.Service1Soap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
I have googled for this issue and I realize I need to add a client and web bindings in my web.config file. 我已经用谷歌搜索了这个问题,我意识到我需要在我的web.config文件中添加一个客户端和Web绑定。 So I have added below part, But that doesn't solve the problem.
所以我在下面添加了部分,但这并不能解决问题。
<system.serviceModel>
<client>
<endpoint address="http://192.168.1.3/MyFirstWebService/Service1.asmx" binding="basicHttpBinding"
contract="ClassABC" bindingConfiguration ="httpBinding"
name="BasicHttpBinding_IABC" />
</client>
</system.serviceModel>
Looks like I missed binding here in my web server application ? 好像我错过了在Web服务器应用程序中绑定的位置? Hw can I solve this problem, any reference or links to where I should start or any example application will be great help.
我可以解决这个问题,任何我应该从哪里开始的引用或链接,或者任何示例应用程序都将提供很大的帮助。 Do I need to change anything in my Web Service or web.config file changes should be enough ?
我是否需要更改Web服务或web.config文件中的任何内容,更改就足够了吗?
If you have more than one binding inside <configuration><system.serviceModel><bindings>
, then you need to pick one by name and pass it to the constructor of your web service client to eliminate the ambiguity. 如果
<configuration><system.serviceModel><bindings>
内有多个<configuration><system.serviceModel><bindings>
,则需要按名称选择一个<configuration><system.serviceModel><bindings>
,并将其传递给Web Service客户端的构造函数,以消除歧义。
For example: 例如:
var svcClientObj = new CustomWebSvcClient("BasicHttpBinding_ICustomWebSvc_OverHttp");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.