doedje / jquery.soap

This script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
352 stars 148 forks source link

Success function doesn't get run on success #133

Closed dhuber666 closed 3 years ago

dhuber666 commented 4 years ago

Hi man,

it's me again. I fixed the cors problem and now I'm getting into the real business of the package.

When I send my request it's working now (as I can see on the server). But the success function doesn't run. When I console.log it or debug it, it does not run.

What am I missing.

Here is the code:

$.soap({
  url: "https://mycompany/webservice",
  method: "myMethod",
  HTTPHeaders: {
    Authorization: "Basic " + btoa(username + ":" + password)
  },

  data: {
    ...myValues
  },

  success: function(soapResponse) {
    console.log("we have success", soapResponse);
    console.log("hellooooo");
    // do stuff with soapResponse
    // if you want to have the response as JSON use soapResponse.toJSON();
    // or soapResponse.toString() to get XML string
    // or soapResponse.toXML() to get XML DOM
  },
  error: function(SOAPResponse) {
    console.log("this is the error", SOAPResponse);
  }
});

//EDIT: After further investigating I found out that the function does run. Because it's stopping when I put the debugger in it. But it does not console.log anything. That is super weird. (my guess is, the console is not ready yet when I want to log it, but why so?)

Also if I find a librarie that parses XML to JSON how can I gett access to the XML document returned by the soapResponse? Which key is it?

The soapResponse is an object like this:

2019-11-25 14_25_15-Window

I would appreciate your help.

And thx again for the package my man.

Steven2160 commented 4 years ago

Hi,

Does anyone get answer? I got similar issue. When the method process in short time, success/error will be triggered but when the method processing too long (about > 10 sec), success/error will not be triggered. It shows "Session state: aborted" when I capture in fiddler. And the sessionState time out in web config doesn't take effect.

Thanks, Steven

doedje commented 4 years ago

@dhuber666 I am sorry to have missed/forgotten about your issue and never got back to you... I hope you figured out how to fix your problem by now.. ;)

@Steven2160 I would need an example that reproduces your problem to be able to properly debug your case...

Steven2160 commented 4 years ago

Hi @doedje,

I reviewed the solved issues and got a solution. My problem can be resolved by add time out attribute. image Not sure if it will work for @dhuber666 .

Thanks, Steven

doedje commented 4 years ago

As stated in the documentation: https://github.com/doedje/jquery.soap/blob/master/doc/options.md#timeout or in the code of jquery.soap.js itself, line 57: 5000 ms.

Steven2160 commented 4 years ago

Thanks @doedje. Already noticed it in the global config.