簡體   English   中英

如何從Angular js腳本調用WCF服務WebGet方法

[英]how to call WCF service WebGet method from Angular js script

public interface IService1
{
    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json,
         ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetEmployeeA?id={id}")]
    EmployeeA GetEmployeeA(int id);

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetEmployeeJSON?str={str}")]
    string GetEmployeeJSON(string str);
}

我想使用angularJS腳本調用上述方法...我嘗試了使用param的httpget():

$http({ url: yourURL, method: "GET", params: {: params:" ''} }); 

具體問題是什么? 如果您這樣做,它應該可以正常工作:

$http({
    url: "http://yourURL/GetEmployeeA", 
    method: "GET",
    params: {id: 123}
});

分別

$http({
    url: "http://yourURL/GetEmployeeJSON", 
    method: "GET",
    params: {str: 'foo'}
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM