我的宁静端点是什么,如何正确配置?

时间:2018-07-09 16:13:53

标签: c# json wcf-rest

我正在使用c#配置一个静态的api服务器和客户端(在部署之前进行测试)。

似乎有很多不同的方法来解决它,我正在尝试遵循一种方法,但是由于所有的选择,我一直很难找到正确的文档和对我正在尝试的内容的支持。

问题是,尽管服务器似乎已设置好,但我可以将其添加为客户端项目的引用,但是当我实际尝试使用get方法时,它会引发有关未配置端点或存在端点的错误没有配置文件。

这是服务器端的代码:

 [OperationContract]

    [WebInvoke(Method = "GET",

        ResponseFormat = WebMessageFormat.Json,

        BodyStyle = WebMessageBodyStyle.Wrapped,

        UriTemplate = "getreadings/{site}/{start}/{end}")]
   // string getreadings(string site, string start, string end);
    List<GaugeData> GetRainGaugeData(string site, string start, string end);

Web配置:

  <services>

  <service name="telogapi.RainService">
    <endpoint address="json" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="telogapi.IRainService"></endpoint>

  </service>

最后是我非常简单的客户端代码:

ServiceReference1.RainServiceClient client = new ServiceReference1.RainServiceClient("http://localhost:65534/json");


       ServiceReference1.GaugeData[] results =  client.GetRainGaugeData("Pond", "05/05/2018", "06/06/2018");

感谢您的帮助。

0 个答案:

没有答案
相关问题