Post edited to clarify:

I found the following code that allows me to query my 3dCart store database and dump the information into a sheet. I tried upgrading to the new Apps Script runtime powered by Chrome V8 and it fails. I get the following error:

ReferenceError: Xml is not defined (line 12, file "Utilities")

var api_key = "";
var store_url = "";
// These settings can be hardcoded or placed in the "SETTINGS" sheet

function queryCart(strSql) {
  // This script relies on the SoapService which was deprecated beginning 7/2013 and will be unavailable 2/2014!

  var wsdl = SoapService.wsdl("http://api.3dcart.com/cart_advanced.asmx?WSDL");
  var cartAPI = wsdl.getService("cartAPIAdvanced");

  var param = Xml.element("runQuery", [
                Xml.attribute("xmlns", "http://3dcart.com/"),
                Xml.element("storeUrl", [store_url]),
                Xml.element("userKey", [api_key]),
                Xml.element("callBackURL", [""]),
                Xml.element("sqlStatement", [strSql])

//  var envelope = cartAPI.getSoapEnvelope("runQuery", param); // Use to examine request without sending

  var result_full = cartAPI.invokeOperation("runQuery", [param]);
  var result = result_full.Envelope.Body.runQueryResponse.runQueryResult;

  return result;

apps script screenshot from script editor with information

  • Welcome. The question is too broad and unclear. Please edit the question to limit it to one thing and add more details.. – Rubén Feb 19 '20 at 15:31
  • Thank you Rubén. I have edited. – Gary D Feb 20 '20 at 16:32
  • It's worthy to note that your code says // This script relies on the SoapService which was deprecated beginning 7/2013 and will be unavailable 2/2014! Is this service is still working in 2/2020? – Rubén Feb 20 '20 at 18:48
  • I was able to revert to legacy from V8 and the code is functioning again. It would appear that I need to find a new method before the service is obsolete. Thank you for your response. – Gary D Feb 21 '20 at 19:23
  • I just added to my answer a link to a related question – Rubén Feb 21 '20 at 19:28

The major problem with the code that you found is that it's using a service that "will be retired" in 2014 and we are in 2020.

I had a very similar problem the last week regarding the Xml Service. What I did was to revert my project to use Rhino instead of Chrome V8,

The above because there isn't another Google Apps Script built-in service that works as the Xml Service. The "closest" is the XmlService Service

In my case, I was using it for for HTML parsing but the workarounds/solutions are too complex for the needs of my project.

One workaround for HTML parsing is to use string handling techniques like using regular expressions which is not an easy task because HTML cannot always be parsed effectively by using them, actually some people discourages this.

The pro way to go is to use a HTML parsing code library. You could ask for a software recommendation in https://softwarerecs.stackexchange.com and/or search for questions about HTML parsing using Google Apps Script / JavaScript in https://stackoverflow.com.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.