我有一个简单的WCF服务:
displayMetrics.widthPixels * (sizeX/100.0f);
我想在控制台应用程序中自行托管:
namespace Vert.Host.VertService
{
[ServiceContract]
public interface IRSVP
{
[OperationContract]
bool Attending();
[OperationContract]
bool NotAttending();
}
public class RSVPService : IRSVP
{
public RSVPService()
{
}
public bool Attending()
{
return true;
}
public bool NotAttending()
{
return true;
}
}
}
所以我使用这个app.config
class Program
{
public static void Main()
{
// Create a ServiceHost
using (ServiceHost serviceHost = new ServiceHost(typeof(RSVPService)))
{
// Open the ServiceHost to create listeners
// and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
}
}
}
据我所知,这个设置会让<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
<system.serviceModel>
<services>
<service name="Vert.Host.VertService.RSVPService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Vert" />
</baseAddresses>
</host>
<endpoint
address="/RSVP"
binding="basicHttpBinding"
contract="Vert.Host.VertService.IRSVP" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
作为一个有效的REST URI从任意HTTPClient调用,但是调用无限期挂起或者以http://localhost:8080/Vert/RSVP/Attending
回来(I&# 39; m使用高级REST客户端)
我缺少什么?
答案 0 :(得分:2)
您在所有设置中都是正确的......直到您停止输入代码并开始告诉我您拥有的内容。 :)
您创建的是std WCF服务,您可以使用服务代理或ChannelFactory访问它,但它将使用SOAP按原样与您通信。
您需要this tutorial将此Web服务转换为RESTFUL服务,以回馈Json / pox。