当我从RestClient调用wcf服务时收到错误:
[EndpointNotFoundException]:没有频道主动收听'http://localhost/Test/TestService.svc/TestMethod' ;.这通常是由错误的地址URI引起的。确保将消息发送到的地址与服务正在侦听的地址匹配。
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="80" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TestService.TestService" behaviorConfiguration="mexBehaviour">
<endpoint address="TestService" binding="basicHttpBinding" contract="TestService.ITestService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost/Test/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
已搜索过许多类似问题但未解决,请帮助..
这是服务代码:
namespace TestService
{
[ServiceContract]
public interface ITestService
{
[OperationContract, WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
string TestMethod();
}
}
namespace TestService
{
public class TestService: ITestService
{
public string TestMethod()
{
return "Hello";
}
}
}
答案 0 :(得分:1)
添加UriTemplate =“Test /”
Model.xcdatamodeld
配置:
namespace TestService
{
[ServiceContract]
public interface ITestService
{
[OperationContract,WebInvoke(Method = "POST",ResponseFormat = WebMessageFormat.Json,UriTemplate = "Test/")]
string TestMethod();
}
}