I have a WCF service defined as follows, which I know is working (producing a valid result):
[ServiceContract(Namespace="XXX.CES.Applet")]
public interface IAppletService
{
[OperationContract(Action = "GetDefinitionJSON")]
[WebGet(UriTemplate = "/GetDefinitionJSON?request={jsonRequest}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetAppletDefinitionJSON(string jsonRequest);
}
I have the following controller defined, can verify that it is reaching the service and that the response is what I expect it to be (a JSON string) using FireBug:
angular.module('Applet',['ngResource']);
function AppletController($scope,$resource) {
$scope.url = 'http://localhost/CESAppletService/AppletService.svc/:action';
$scope.appletRequest =
{
AppletName: 'FPTotalForgeTime',
ModelName: 'CES_ProtoType_Rings_Model',
EntityName: 'ForgeWCTimes_ForgeTimeTotal',
EntityType: 'Decimal',
Value: ''
};
$scope.getDefinition = $resource($scope.url,
{action:'GetDefinitionJSON',request:angular.toJson($scope.appletRequest),callback:'JSON_CALLBACK'});
$scope.AppletInputs = $scope.getDefinition.get();
}
When I look at the resulting $scope.AppletInputs in FireBug or by rendering them in the page, the object looks like the following (only partial):
""" 1 "{" 2 "\" 3 """ 4 "A" 5 "p" 6 "p" 7 "l" 8 "e" 9 "t" 10 "I" 11 "n" 12 "p" 13 "u" 14 "t" 15 "s" 16 "\" 17 """ 18
The actual service result is:
"{\"AppletInputs\":[{\"AllowedValues\": [],\"EntityName\":\"Forge_OD\",\"InputLabel\":\"OD\",\"InputType\":\"Decimal\",\"Value\":null},{\"AllowedValues\":[],\"EntityName\":\"Forge_ID\",\"InputLabel\":\"ID\",\"InputType\":\"Decimal\",\"Value\":null},{\"AllowedValues\":[],\"EntityName\":\"Forge_Face\",\"InputLabel\":\"Face\",\"InputType\":\"Decimal\",\"Value\":null},{\"AllowedValues\":[\"G43400XXX\",\"S30403XXX\",\"S31603XXX\",\"N06625XXX\",\"A96061XXX\",\"G43400GE2\",\"E16587M01\"],\"EntityName\":\"MaterialGrade\",\"InputLabel\":\"Grade\",\"InputType\":\"List\",\"Value\":null}],\"AppletName\":\"FPTotalForgeTime\",\"AppletType\":\"Decimal\",\"AppletVersion\":\"\",\"EntityName\":\"ForgeWCTimes_ForgeTimeTotal\",\"ModelName\":\"CES_Prototype_Rings_Model\"}"
What am I doing wrong and how do I fix it? I REALLY want to be able to use Angular for this project, but this is eating my lunch.