Skip to content Skip to sidebar Skip to footer

Calling A C# Webservice From The Success Function Of Another Webservice?

My question is simple. Can you call a C# webservice from the Success function of another webservice? I think that the answer is no. I have a login webservice which is called whe

Solution 1:

How about to use jQuery.ajax()?

functionFunc1() {
    $.ajax({
        url:'MyWebService.asmx/Func1',
        success:Func1Success,
        error: function () {
            alert('there was an error!');
        },
    });
    returnfalse;
}
functionFunc1Success(output){
  $.ajax({
        url:'MyWebService.asmx/Func2',
        success:Func1SuccessToSuccess,
        error: function () {
            alert('there was an error!');
        },
    });
}
functionFunc1SuccessToSuccess() {
    returnfalse;
}

Solution 2:

You definitely can.

Just to give a suggestion/advice theoretically, you can have 1 local variable for the status response of the first web service method, you can have it as boolean, representing the success of the first invocation. Then sequentially, you can call the other web service method if your local variable matches your success condition.

What I provided is just an idea, for a more specific answer, I recommend you posting the actual code you're working on.

Thanks.

Solution 3:

I am assuming you are using .cs files on your server and then calling them from android. If this is what you are doing then there is one way to call a method on success of another method. Just make two .cs files say x and y and store it on your server. Then call one of them from android (x) and then make object of y in x and that will be all. for eg. This is my one .cs file named abc.cs which il call from android.

 [WebMethod]
 public xyz IsLoggedIn()
 {
    xyz example = new xyz();
    //do something
    .
    .

    return example;
  }

now xyz.cs will be:

[WebMethod]
 publicvoidonSuccessofIsLoggedIn()
 {
    //do something
    .
    .
  }

i hope this helps.... All this is just based on assumption though...please be clear about what you are using and we will be also more clear in our answers.

Post a Comment for "Calling A C# Webservice From The Success Function Of Another Webservice?"