[OperationContract]
[FaultContract(typeof(DcCustomFaultMessage))]
[WebGet(ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/GetHistoryData")]
List<DcHistoryData> GetHistoryData(DcHistoryCriteria criteria);
or
With multiple parameters
[OperationContract]
[FaultContract(typeof(DcCustomFaultMessage))]
[WebGet(ResponseFormat = WebMessageFormat.Json,
RequestFormat=WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/GetHistoy?ReportingId={ReportingId}&ErrorCode={ErrorCode}&OriginatorCode={OriginatorCode}&PrimaryAssetClass={PrimaryAssetClass}&MessageType={MessageType}&FeedbackType={FeedbackType}&ReportType={ReportType}&RegionCode={RegionCode}&errorstatus={errorstatus}")]
Stream GetHistoryData(string ReportingId, string ErrorCode, string OriginatorCode, string PrimaryAssetClass, string MessageType, string FeedbackType, int ReportType, string RegionCode, string errorstatus);
Which is a better way to do it? How to call this from AngularJS?
I am able to call this service if the service is defined without parameter with below call from AngularJS:
$http.get("http://localhost:55467/WCFServiceHost/DFAService.svc/GetHistorydata")
.success(function (result) {
alert('got history data');
$scope.HistoryRejections = $.parseJSON(JSON.parse(result));
}).error(function (data, status, headers, config) {
$scope.attributesData = null;
$scope.showmessage("error", "error");
});
I don't know how to do this in case of multiple parameter or datacontract parameter? please help.
A HTTP GET request can't contain data to be posted to the server. However you can add a query string to the request.
angular.http provides an option for it params You can use:
$http({
url: yourURL,
method: "GET",
params: {ReportingId: '', ErrorCode: ''}
});
Or if you want to use $http.get():
$http.get(yourURL, {
params: {ReportingId: '', ErrorCode: ''}
});