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

Unable to determine cause of this error #39

Closed todd-lockhart closed 10 years ago

todd-lockhart commented 10 years ago

[Error] TypeError: 'undefined' is not a function (evaluating '$.soap') (anonymous function) (DynamicPage.aspx, line 314) dispatch (jquery-1.10.1.min.js, line 5) handle (jquery-1.10.1.min.js, line 5)

Have $.soap calls tied to click event as follows -

$('#sbutton').click(function() {
  var webServiceUrl = '/xweb/secure/netFORUMXML.asmx';

  var tokenSOAP = ['<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">',
    '<soapenv:Header/>',
    '<soapenv:Body>',
      '<ns:Authenticate>',
        '<ns:userName>someusername</ns:userName>',
        '<ns:password>somepassword</ns:password>',
      '</ns:Authenticate>',
    '</soapenv:Body>',
  '</soapenv:Envelope>'];

var tokenData = tokenSOAP.join('');

$.soap({
  url: '/xweb/secure/netFORUMXML.asmx',
  data: tokenData,
  success: function(SOAPResponse) {
    tokenResponse = SOAPResponse.toXML();

    var activeToken = $(tokenResponse).find("Token").text();
    alert(activeToken);

    var jsonString = form_data_string;
    jsonSOAP = ['<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">',
      '<soapenv:Header>',
        '<ns:AuthorizationToken>',
          '<ns:Token>',
            activeToken,
          '</ns:Token>',
        '</ns:AuthorizationToken>',
      '</soapenv:Header>',
      '<soapenv:Body>',
          '<ns:ExecuteMethod>',
             '<ns:serviceName>someservice</ns:serviceName>',
             '<ns:methodName>somemethodname</ns:methodName>',
                '<ns:parameters>',
                   '<ns:Parameter>',
                      '<ns:Name>jsonData</ns:Name>',
                         '<ns:Value>',
                            jsonString.split('{').join('[|').split('}').join('|]'),  // because it uses {} to denote parsed variables
                         '</ns:Value>',
                   '</ns:Parameter>',
                '</ns:parameters>',
          '</ns:ExecuteMethod>',
      '</soapenv:Body>',
  '</soapenv:Envelope>'];

  var soapData = jsonSOAP.join('');

      $.soap({
        url: '/xweb/secure/netFORUMXML.asmx',
        data: soapData,
        success: function(SOAPResponse) {
          alert('yeah, baby....');
        },
        error: function(SOAPResponse) {
        console.log(SOAPResponse.toString());
        }
      });

  },
  error: function(SOAPResponse) {
    console.log(SOAPResponse.toString());
  }
 });

});
doedje commented 10 years ago

could you specify on which point in the above code you get the error? Do you see any of the alerts?

todd-lockhart commented 10 years ago

Remy,

Thanks for responding. I get the error at the very first $.soap( call with it highlighting the open parenthesis.

Todd


Todd Lockhart Director, IS todd.lockhart@ajj.com 856-256-2353 Anthony J. Jannetti, Inc. An AMCI Accredited Association Management Company

Sent from mobile

On Feb 27, 2014, at 6:06 AM, Remy Blom notifications@github.com wrote:

could you specify on which point in the above code you get the error?

— Reply to this email directly or view it on GitHub.

doedje commented 10 years ago

So basically if you would do:

$.soap();

You already get an error?

todd-lockhart commented 10 years ago

Yes, exactly.


Todd Lockhart Director, IS todd.lockhart@ajj.com 856-256-2353 Anthony J. Jannetti, Inc. An AMCI Accredited Association Management Company

Sent from mobile

On Feb 27, 2014, at 7:32 AM, Remy Blom notifications@github.com wrote:

So basically if you would do something like:

$.soap(); You already get an error?

— Reply to this email directly or view it on GitHub.

doedje commented 10 years ago

Then it seems that the $.soap function is not present at the moment you try to call it...

todd-lockhart commented 10 years ago

Sorry, was driving :)

No errors on page about loading jquery.soap.js and here is snipped from head -

And $ is definitely jQuery, as the other $ jQuery calls in my original code block all work fine. Tried jQuery.soap() anyway, but it throws the same error.

It does seem like it's not loading jquery.soap.js for some reason... but no clue why.

Todd

----- Original Message -----

From: "Remy Blom" notifications@github.com To: "doedje/jquery.soap" jquery.soap@noreply.github.com Cc: "todd-lockhart" todd.lockhart@ajj.com Sent: Thursday, February 27, 2014 7:43:52 AM Subject: Re: [jquery.soap] Unable to determine cause of this error (#39)

Then it seems that the $.soap function is not present at the moment you try to call it...

* did you include jquery.soap.js in the page? 
* is it correctly loading? 
* maybe $ is not jquery: try jQuery.soap() instead? 

— Reply to this email directly or view it on GitHub .

doedje commented 10 years ago

Well, better drive safe!

If indeed jquery.soap.js is not loaded properly, dive into that.... something to do with permissions maybe? I don't know...

todd-lockhart commented 10 years ago

Well, I placed a test call to $.soap further up in my code and it works fine... so I suspect I've made a syntax error somewhere :) I'll find it! Many thanks for the plugin and the responses!