12 Replies Latest reply: May 14, 2004 10:06 PM by (Sanna_Minski) RSS

    Calling an ASP from a Workflow process map

    Community Member
      Has anyone ever called an ASP from a process map? My code is written in BasicScript but I'm having problems with the XMLHTTP object properties and methods not being recognized. My snippet of code that isn't working is as follows:
      ---
      Set objXML = CreateObject("Microsoft.XMLDOM")
      objXML.async = False

      If objXML.Load(strASPLocation) Then

      Set objNodeList = objXML.getElementsByTagName("USER")

      Else

      msgbox "XML Load failed. Please ensure the following ASP page is valid:" & chr(13) & strASPURL

      End If
      ---

      It fails on the objXML.asyc = False line as well as on the objXML.Load line and the objXML.getElementsByTagName line. Any ideas?

      Thanks.
        • 1. Re: Calling an ASP from a Workflow process map
          Perry,

          If I understand you correctly you are mearly calling an ASP page and retrieving the value returned afterwards? ( You won't be posting anything to it? )
          • 2. Re: Calling an ASP from a Workflow process map
            Community Member
            Hi Jon,

            Yup, exactly. It's a very simple ASP that just connects to the WorklistShares table and retrieves the names of the users with access to the specified user's worklist. I've done this many times from forms using VBScript, I just can't get it to work from the process map using either BasicScript or JScript. Probably due to my inept scripting skills. I tried to get Tech Support to help but I got the old "this is outside the scope of support" line. Any help you could give me would be great!

            Thanks.
            • 3. Re: Calling an ASP from a Workflow process map
              Community Member
              Perry,

              Something I quickly put together. If need be you can expanded to read\parse an xmlDocument. The following code would reside within the common script container.

              NOTE: This assumes you are using MS XMLHTTP 4.0 SP2 version.

              /******************************************************************
              uses xmlHTTPGET to post to web server calling corresponding ASP
              OUT: ASP response
              ******************************************************************/
              function XMLHTTPGET() {

              try {
              // instantiate the xmlhttp object
              var objXMLHTTP = new ActiveXObject("MSXML2.ServerXMLHTTP.4.0");
              // Initializes a request and specifies the method
              objXMLHTTP.open("GET", "http://THESERVERNAME/Response.asp", false);
              // Sends an HTTP request to the server and receives a response
              objXMLHTTP.send();
              // process it
              var strResult = objXMLHTTP.responseText;

              objXMLHTTP = null;

              return strResult;

              }
              catch ( e ) {

              Agent.log("PROCESS ERROR::XMLHTTPGET() " + e.description);

              }
              }
              • 4. Re: Calling an ASP from a Workflow process map
                Community Member
                Thanks a lot, Jon. That's a huge help!

                Can I replace the .responseText with .getElementsByTagName("TAG")? I only want to retrieve a specific tag value from the ASP. I've tried putting that in but the value I get back is "undefined". Is .getElementsByTagName("TAG") a valid method in JScript?

                Also, do you have a good web reference for JScript programming? I haven't found a good one. MSDN is only somewhat helpful. Thanks!
                • 5. Re: Calling an ASP from a Workflow process map
                  Community Member
                  Perry,

                  I believe you would have to first replace '.responseText' with '.responseXML' ( assuming that your ASP is returning some sort of XML doc ).

                  Afterwards you should be able to use the getElementsByTagName() method of the DOMDocument object. If not you can instantiate the DOMDocument obj, return the xmlDoc into it ie ( .responseXML.xml), then use the above said method to grab your Tag.

                  -Else-

                  If you're just after the value of the Tag and not the entire XML doc then you could save yourself the overhead and just return that.

                  Just a thought.
                  • 6. Re: Calling an ASP from a Workflow process map
                    Community Member
                    Hi Jon,

                    I only want the value of the tag, not the entire XML doc. I tried replacing .responseText with .getElementsByTagName("TAG") but the value is returned as "undefined".
                    • 7. Re: Calling an ASP from a Workflow process map
                      Community Member
                      Perry,

                      Sorry, been travelling a lot with work... Okay so, if I understand this correctly you just want the value held within a single xmldoc element.

                      If I may ask... Why are you returning an entire xmldoc just to retrieve the value of a single element? Seems like a lot of overhead to me; By creating a xmldom object, loading in the xmldoc and retrieving the value of a single element.

                      Why not just return the rs result thru the ASP using the Response.Write() method, then retrieve that from the ".responseText" as was previously illustrated.

                      If you need to use xml then I don't see why you can't retrieve the xml document by "srvXmlHttp.responseXML.xml" and load that result into a waiting xmldomdocument, then parse the element value.

                      -Jon-
                      • 8. Re: Calling an ASP from a Workflow process map
                        Community Member
                        Hi Jon,

                        Thanks again for your reply. A lot of the problem here is my lack of experience and programming knowledge with JScript and XML. I basically did what you describe and used the .responseText method and then parsed on the element value - that worked.

                        Next problem: would you happen to have a JScript function that sends an e-mail message to a list of users? I have one in BasicScript that I'm trying to convert but I'm having problems.

                        Thanks a lot!

                        Perry
                        • 9. Re: Calling an ASP from a Workflow process map
                          Community Member
                          Should probably start a new forum for this as it would make it easier for others to find information. But, I don't see what you can't model it after the basic script sample, however instead you could pass in an array of usernames that will be receiving the email and loop thru each element grabbing the email address from the Users object.

                          -OR-

                          If it's a list that doesn't really need to be that dynamic you could just build a string of fully qualified email addresses separated by ";" then pass that directly to the Email.To property.

                          -Jon-
                          • 10. Re: Calling an ASP from a Workflow process map
                            Community Member
                            John,

                            I've tried basically what you described in your second option. However, in BasicScript the .To property doesn't seem to need a fully qualified e-mail address; that is, I just pass the User.DisplayName property. Is it different in JScript? Do I need to pass the e-mail address instead? And does the .To property accept a semi-colon delimited list?

                            Thanks.

                            Perry
                            • 11. Re: Calling an ASP from a Workflow process map
                              Community Member
                              Yes, there is a difference between the two languages the PDF manuals explain it pretty well.
                              • 12. Re: Calling an ASP from a Workflow process map
                                Community Member
                                Perry,

                                In fact, if you have a look at the email samples in the documentation of WorkflowServer, you will be able to find a complete code sampel for sending emails like that. (With one exception, the sample calling statement has an error in it, suggesting you could use null value for variables that are not used (I think it was the BCC field), which will not work. Replace the null with an empty string (''), and you can use that function.)

                                Cheeers,
                                Sanna