Can';t更正控制台应用程序中承载的此基本WCF服务中的错误
我有一个基本的WCF服务托管在一个控制台应用程序中,我不能从另一个控制台应用程序中使用它 我在学习WCF,所以我试图让它和一本书一起工作 当我尝试使用该服务时,会出现以下错误Can';t更正控制台应用程序中承载的此基本WCF服务中的错误,wcf,Wcf,我有一个基本的WCF服务托管在一个控制台应用程序中,我不能从另一个控制台应用程序中使用它 我在学习WCF,所以我试图让它和一本书一起工作 当我尝试使用该服务时,会出现以下错误 Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/
Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/HelloWorldService that could accept the message. This is often caused by an incorrect address or SOAP action...
但服务运行良好:
我正在使用VS2012
解决方案的总体结构是:
<system.serviceModel>
<services>
<service name="MyWCFServices.HelloWorldService"
behaviorConfiguration="HelloWorldServiceBehavior">
<endpoint address="HelloWorldService"
binding="basicHttpBinding"
contract="MyWCFServices.IHelloWorldService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HelloWorldServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我以管理员身份运行VS。您的客户端地址不正确。svc后面有一个正斜杠
address="http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/HelloWorldService"
如果您在服务主机上将地址留空,那么您就不需要在结尾处使用“/HelloWorldService”。对不起,地址中有斜杠,但我在编辑问题时不知何故删除了它。你把地址留空是什么意思?端点的定义迫使我指定地址、绑定和契约。我现在知道问题出在哪里了。我必须先运行服务,然后再运行客户端。我认为我已经将解决方案的启动配置为按该顺序进行。但这是不正确的。谢谢你的回答。根据我提出的问题,你的答案是正确的
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHelloWorldService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:6599/HostCmdLineApp/HelloWorldService.svc
HelloWorldService"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IHelloWorldService"
contract="IHelloWorldService" name="BasicHttpBinding_IHelloWorldService" />
</client>
</system.serviceModel>
static void Main(string[] args) {
var client = new HelloWorldServiceClient();
Console.WriteLine(client.GetMessage("Rafael Soteldo"));
}
address="http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/HelloWorldService"