1

I create application for mobile use ionic framework connect to sql server 2008 through ASP.NET webservice. When I use SOAP header AngularJs $http.post() does not send data.

Login Method

public AuthHeader Authentication;

[SoapHeader("Authentication", Required = true)]
[WebMethod(Description = "Returns login User")]
public string Login(string Username, string Password)
{
    if (Authentication.Username.ToLower() != "admin" ||
      Authentication.Password.ToLower() != "admin@123")
        throw new SoapException("Unauthorized",
            SoapException.ClientFaultCode);

    Password = Encrypt.GetSHA1HashData(Password);
    var result = EmployeeService.Login(Username, Password);
    if (result == null)
        return "-1";
    return JsonConvert.SerializeObject(result);
}

Angular Service

.service('LoginService', function ($q, $http) {
return {
    loginUser: function (name, pw) {
        var deferred = $q.defer();
        var promise = deferred.promise;

        $http.post('http://192.168.187.1/SalesServices/MobileService.asmx/Login',
            {
                Username: 'thao.huynh',
                Password: 'thao.huynh'
            }).then(function (response) {
            deferred.resolve(response.data);
           // console.log(response.data);
        }).catch(function (response) {
            deferred.reject('error', response.status, response.data);
            console.error('error', response.status, response.data);
        }).finally(function () {
           // console.log("finally finished gists");
        });

        promise.success = function (fn) {
            promise.then(fn);
            return promise;
        }
        promise.error = function (fn) {
            promise.then(null, fn);
            return promise;
        }


        return promise;

    }
}
Aracthor
  • 5,757
  • 6
  • 31
  • 59

1 Answers1

0

For this you can refer this answer... It shows the simplest way to call a service using soap

https://stackoverflow.com/a/11404133/3156647

Community
  • 1
  • 1
tarzanbappa
  • 4,930
  • 22
  • 75
  • 117