当我返回时Employee
类正常工作,但我只需要几个属性,所以我试图使它在浏览器上得到ERR_CONNECTION_REFUSED
,但在代码后面没有错误。返回服务中的json对象
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "employees")]
public object GetEmployees()
{
var c = Employee.GetList().Select(x => new { id = x.Id, title = x.Title, person = x.FullName});
return c;
}
[OperationContract]
object GetEmployees();
WebConfig
<service name="FOO.FOO.FOOService">
<endpoint address="http://localhost:8733/FOOService" binding="webHttpBinding" contract="FOO.FOO.IFOOService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/FOOService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
多放些细节到你的问题(确切的错误信息,错误位置等) –
更新,这是我的所有的信息。现在,即使你可以建立一个样本项目来测试。 – Mert