1

I've got a wcf Service which has a method which send its output in jsonformat. The service is hosted in an https-Environment.

i'm calling it with angularjs-resource:

var hrdemo = angular.module('hrdemo', ["ngResource"]);

hrdemo.controller('HrDemoCtrl', function ($scope, hrdbservice) {
    $scope.items = hrdbservice.get({ 'Id': 1 });
    var a = $scope.items.length;
});

hrdemo.factory('hrdbservice', function ($resource) {
    return $resource('http://hrservice/HrService.svc/:Id', { Id: "@Id" }, { get: { method: 'JSONP' } });
});

Angularjs runs in an ASP.Net-Web Application. When calling the Service I get something like an xhr-problem.

1) How can i authenticate with my Windows authentication over angularjs 2) What can I do to fix the xhr-problem?

12
  • what is the error ? can you run the webservice from browser by typing the url in address bar? Commented Aug 20, 2014 at 9:31
  • the error happens when using the Standard get without the method "JSONP" in the $resource-call, Error: Exception was thrown at line 8473, column 7 in localhost:44304/Scripts/angular.js 0x80070005 - JavaScript runtime error: Access is denied. Commented Aug 20, 2014 at 9:52
  • the Service works when using the browser Commented Aug 20, 2014 at 9:53
  • why jsonp? are you doing cross-domain request ? Commented Aug 20, 2014 at 9:56
  • Yes, my WCF service is on another machine. Commented Aug 20, 2014 at 10:04

1 Answer 1

2

May the withCredentials option is what you are searching for $http.post(url, {withCredentials: true, ...}). Also there is a specific shortcut for performing a JSONP request in AngularJS - $http.jsonp()

AngularJS Docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.