简体   繁体   English

wcf-代码中的客户端绑定-错误:“没有端点监听.svc来接受消息。”

[英]wcf - Client Binding in Code- Error : “There was no endpoint listening at .svc that could accept the message.”

I created a webservice in wcf which have OperationContract like this : 我在wcf中创建了一个具有OperationContract的Web服务,如下所示:

[OperationContract]
string getDate(string id)

then I create a client console project and added service reference with url of " http://localhost:58536/RealWorldServices/RealWorld.svc " and it completely work. 然后,我创建一个客户端控制台项目,并使用“ http:// localhost:58536 / RealWorldServices / RealWorld.svc ”的URL添加服务引用,它可以完全正常工作。

but i need to bind service reference in code. 但是我需要在代码中绑定服务引用。 i used Svcutil.exe "webservice url" command in visual studio command prompt for creating "Service1.cs" . 我在Visual Studio命令提示符中使用了Svcutil.exe“ webservice url”命令来创建“ Service1.cs”。 then I added it to my client console project. 然后将其添加到我的客户端控制台项目中。 by adding these code to ot : 通过将这些代码添加到ot中:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://localhost:58536/ServiceReference1.IService1.svc");
Service1Client client = new Service1Client(binding, address);
string st = client.GetData("10");

but in last line which is exactly the same as calling method in previous way (adding in add webservice way) but I see I recieve this Error 但在最后一行中,这与以前的调用方法完全相同(以添加webservice的方式添加),但我看到我收到此错误

An unhandled exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll mscorlib.dll中发生了类型为'System.ServiceModel.EndpointNotFoundException'的未处理异常

Additional information: There was no endpoint listening at http://localhost:58536/ServiceReference1.IService1.svc that could accept the message. 附加信息:在http:// localhost:58536 / ServiceReference1.IService1.svc上没有侦听终结点的端点,可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

Maybe this could be the issue?? 也许这可能是个问题??

In you example you are calling GetData: 在您的示例中,您正在调用GetData:

string st = client.GetData("10");

But your contract says getDate 但是你的合同说getDate

[OperationContract]
string getaDate(string id)

I believe one of the default methods created in the service is called GetData which accepts an int . 我相信服务中创建的默认方法之一称为GetData,它接受一个int

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP核心“没有在[url]上侦听的终结点可以接受该消息。 ” - ASP Core “There was no endpoint listening at [url] that could accept the message. ” WCF:没有端点在侦听,可以接受消息 - WCF: There was no endpoint listening at, that could accept the message 没有端点监听GPService可以接受该消息。 这通常是由不正确的地址或SOAP操作引起的。 - There was no endpoint listening GPService that could accept the message. This is often caused by an incorrect address or SOAP action. 在 net.tcp://url 上没有侦听端点可以接受消息。 这通常是由不正确的地址或 SOAP 操作引起的 - There was no endpoint listening at net.tcp://url that could accept the message. This is often caused by an incorrect address or SOAP action 使用WCF Web服务时“没有侦听端点可以接受消息” - “There was no endpoint listening at that could accept the message” when consuming WCF web service 在 {0} 处没有侦听端点可以接受消息。 这通常是由不正确的地址或 SOAP 操作引起的。 (Xamarin 安卓) - There was no endpoint listening at {0} that could accept the message. This is often cause by an incorrect address or SOAP action. (Xamarin Android) 没有端点可以在https://…上侦听该消息。 这通常是由错误的地址或SOAP操作引起的 - There was no endpoint listening at https://… that could accept the message. This is often caused by an incorrect address or SOAP action 没有端点在听……可以接受该消息 - There was no endpoint listening at…that could accept the message 没有端点监听 <url> 可以接受消息 - There was no endpoint listening at <url> that could accept the message 没有端点侦听 (url) 可以接受消息 - There was no endpoint listening at (url) that could accept the message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM