當我返回時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