繁体   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