Rest 具有多种服务和功能的WCF
我正在尝试创建一个WCF,它在一个程序集中提供多个rest服务。为了测试它,我创建了两个服务,它们的内容与服务两个接口的内容相同 我可以使用url获取元数据 localhost/testwebservice/services/Service1.svc?wsdl或 localhost/testwebservice/services/Service2.svc?wsdl ,但当我尝试执行一个方法时 localhost/testwebservice/services/Service1.svc/GetData/0 ,我得到一个DestinationUnrecachable错误 web.config文件是Rest 具有多种服务和功能的WCF,rest,wcf,service,Rest,Wcf,Service,我正在尝试创建一个WCF,它在一个程序集中提供多个rest服务。为了测试它,我创建了两个服务,它们的内容与服务两个接口的内容相同 我可以使用url获取元数据 localhost/testwebservice/services/Service1.svc?wsdl或 localhost/testwebservice/services/Service2.svc?wsdl ,但当我尝试执行一个方法时 localhost/testwebservice/services/Service1.svc/GetDa
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="test.Services.Service1">
<endpoint address="" binding="webHttpBinding"
contract="test.Contracts.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="test.Contracts.IService1" />
</service>
<service behaviorConfiguration="ServiceBehavior" name="test.Services.Service2">
<endpoint address="" binding="webHttpBinding"
contract="test.Contracts.IService2" />
<endpoint address="mex" binding="mexHttpBinding" contract="test.Contracts.IService2" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
每个.svc文件都是这样的
namespace test.Contracts
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "GetData/{value}")]
string GetData(string value);
}
}
namespace test.Services
{
public class Service1 : IService1
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
}
我还希望以localhost/testwebservice/services/services/Service1和localhost/testwebservice/services/service2的形式访问webservice,而不是使用.svc,但我无法配置webservice以删除.svc后缀。我已尝试使用终结点的地址,但无法使其运行。您尚未指定任何终结点地址和基址。谢谢您,Tom,我已尝试将终结点地址分配给服务1和服务2,但我得到了相同的结果,什么是基址?另外,我想知道是否可以以任何方式更改从客户端调用服务的方式,并使用别名而不是.svc文件名。您尚未指定任何端点地址和基址。谢谢您,Tom,我尝试将端点地址分配给Service1和service2,但我得到了相同的结果,什么是基址?另外,我想知道是否可以以任何方式更改从客户端调用服务的方式,并使用别名而不是.svc文件名。