1 2 Previous Next 43 Replies Latest reply: Jul 17, 2012 11:14 PM by BKBK RSS

    Passing CF variables in soap request

    Emily LaMunyon Community Member

      Hello,

       

      I have been successful at getting a return from a third party API. Now I need to use that return (session key) on other soap requests in their API in order to retrieve information. I am storing the session key as a variable and was hoping to use this in subsequent calls to their API, however, it is not working. I am getting an error that tells me the session key is 'invalid and is outside the bounds of an array'. Does anyone know if it is possible to store and pass variables in susbsequest soap requests? Any help would be greatly appreciated!!!!

       

      <!--- WSDL --->
      <cfset wsdl_url="http://someurl?wsdl">

      <!--- Compose SOAP message to send to Web Service--->
          <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   <soapenv:Body>
                       <Login xmlns="http://www.siretechnologies.com/">
            <LicenseKey>licenseKey</LicenseKey>
            <Username>user</Username>
            <Password>pass</Password>
            <LicenseType>2</LicenseType>
            <APIKey>APIKey</APIKey>
            <SiteKey></SiteKey>
            <CryptKey></CryptKey>
            <WebOnly>false</WebOnly>
          </Login>
                    </soapenv:Body>
                </soapenv:Envelope>
          </cfsavecontent>


              <!--- Invoke web service to send message--->
              <cfhttp url="#wsdl_url#" method="post" >
                  <cfhttpparam type="header" name="content-type" value="text/xml">
                  <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/Login">
                  <cfhttpparam type="header" name="content-length" value="#len(soap)#">
                  <cfhttpparam type="header" name="charset" value="utf-8">
                  <cfhttpparam type="xml" name="message" value="#trim(soap)#">
              </cfhttp>
              <p><cfoutput>#xmlFormat(cfhttp.fileContent)#</cfoutput> </p>
              <cfset MyXml = XmlParse(cfhttp.fileContent)>

        <cfdump var="#MyXml#">
       
      <cfset responseNodes = xmlSearch(MyXml,"//*[ local-name() = 'LoginResponse' ]")>
           <cfdump var="#responseNodes#">

      <cfoutput>
      <cfloop from="1" to="#arraylen(responseNodes)#" index="i">
          <cfset BookXML = xmlparse(responseNodes[i])>
      <cfset SesKey = "#BookXML.LoginResponse.LoginResult.XmlText#">
          <b>SessionKey:</b> #BookXML.LoginResponse.LoginResult.XmlText#<br>
          <b>Session Key:#SesKey#
      </cfloop>
      </cfoutput>

      <!--- GETUserId, Next call to API--->
      <cfset wsdl_url="http://someurl/sire.asmx?wsdl">

      <cfset sesKey2 = "#SesKey#">

        

      <!--- Compose SOAP message to send to Web Service--->
          <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   <soapenv:Body>
                       <GetUserId xmlns="http://www.siretechnologies.com/">
                       <SessionKey>sesKey2</SessionKey>
            <UserName>user</UserName>
                       </GetUserId>
                     </soapenv:Body>
                </soapenv:Envelope>
          </cfsavecontent>

        • 1. Re: Passing CF variables in soap request
          Reed Powell MeganK

          You forgot the # marks around the sesKey2 variable in the SOAP request.

          • 2. Re: Passing CF variables in soap request
            Reed Powell MeganK

            didn't mean to het send so soon.  I think you are mis-thinking the action of the line of code

            <cfset sesKey2 = "#SesKey#">

             

            Putting the hash marks inside of the var isn't going to make it automatically evaluate a reference to sesKey2.  All you probalby need to do is to remove that line of code, and in the SOAP replace

            <SessionKey>sesKey2</SessionKey>

            with

            <SessionKey>#sesKey#</SessionKey>

             

            Is the username really "user"? or is that another case where the username is in a var called "user", in which case you'll need hash marks there as well.

             

            -reed


            • 3. Re: Passing CF variables in soap request
              Emily LaMunyon Community Member

              Thanks for the response Reed!

               

              I tried your suggestion and am still getting the same error, it is like the variable is not being passed from above.

               

              <SessionKey>#sesKey#</SessionKey>

               

              Also, user is just a filler for the forum, it is really survweb and that seems to be working well.

               

              Any other thoughts?

              • 4. Re: Passing CF variables in soap request
                Reed Powell MeganK

                What value is being put into the soap xml doc?  Try CFDUMPing it to see. I think you are missing a CFOUTPUT inside of the CFSAVECONTENT tag.  Better yet, stop using the CFSAVECONTENT to create the SOAP document, and use CFXML tag instead.  That way if there are structural problems in the XML doc, you'll get better error reporting.

                 

                -reed

                • 5. Re: Passing CF variables in soap request
                  BKBK CommunityMVP

                  <cfloop from="1" to="#arraylen(responseNodes)#" index="i">

                      <cfset BookXML = xmlparse(responseNodes[i])>

                  <cfset SesKey = "#BookXML.LoginResponse.LoginResult.XmlText#">

                      <b>SessionKey:</b> #BookXML.LoginResponse.LoginResult.XmlText#<br>

                      <b>Session Key:#SesKey#

                  </cfloop>

                   

                  Yet another point besides those Reed Powell has discussed. You are looping across the array responseNodes, but overwriting the one value of sesKey each time. Shouldn't you define sesKey as an array, for example, and write the values like this instead?

                   

                  <cfset sesKey = arrayNew(1)>

                  <cfloop from="1" to="#arraylen(responseNodes)#" index="i">

                      <cfset BookXML = xmlparse(responseNodes[i])>

                      <cfset SesKey[i] = BookXML.LoginResponse.LoginResult.XmlText>

                      <b>SessionKey:</b> #SesKey[i]#<br>

                  </cfloop>

                  • 6. Re: Passing CF variables in soap request
                    Emily LaMunyon Community Member

                    Thanks BKBK!!

                     

                    I tried your suggestion and am still not able to pass the seesion key variable correctly in the bolded text below. Do you think the session key is being overwritten, and that is why it won't work twice? Any other ideas????

                     

                    <cfloop from="1" to="#arraylen(responseNodes)#" index="i">

                        <cfset BookXML = xmlparse(responseNodes[i])>

                        <cfset SesKey[i] = "#BookXML.LoginResponse.LoginResult.XmlText#">

                        <b>SessionKey:</b> #BookXML.LoginResponse.LoginResult.XmlText#<br>

                        <b>Session Key:#SesKey[i]#

                    </cfloop>

                    </cfoutput>

                     

                    <!--- GETFILEPDF --->

                    <cfset wsdl_url2="http://slcsireapp-tst/sirewebsvc/sire.asmx?wsdl">

                     

                     

                     

                        <!--- Compose SOAP message to send to Web Service--->

                        <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>

                             <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                 <soapenv:Body>

                                     <GetUserId xmlns="http://www.siretechnologies.com/">

                                     <SessionKey>#SesKey[i]#</SessionKey>

                                      <UserName>survweb</UserName>

                                     </GetUserId>

                                   </soapenv:Body>

                              </soapenv:Envelope>

                        </cfsavecontent>

                    • 7. Re: Passing CF variables in soap request
                      itisdesign CommunityMVP

                      Emily LaMunyon wrote:

                       

                      <cfset SesKey[i] = "#BookXML.LoginResponse.LoginResult.XmlText#">

                      Hi Emily,

                       

                      If you <cfdump var="#SesKey#" /> are the values identical or unique in every row?

                       

                      Thanks,

                      -Aaron

                      • 8. Re: Passing CF variables in soap request
                        Emily LaMunyon Community Member

                        Thanks Aaron!

                         

                        When I do a dump of #SesKey# I get only one row.

                         

                        Does that help?

                        • 9. Re: Passing CF variables in soap request
                          itisdesign CommunityMVP

                          Emily LaMunyon wrote:

                           

                          When I do a dump of #SesKey# I get only one row.

                          Hi Emily,

                           

                          You're welcome and that does help.  Next question: Are you wanting to make the 2nd API call for every result returned from the 1st API call?

                           

                          Meaning, should the 2nd API call be within this: <cfloop from="1" to="#arraylen(responseNodes)#" index="i"> 2nd_API_call_in_here </cfloop> ?

                           

                          Or the 2nd API call will only be made once, regardless of the number of results from the 1st API call?

                           

                          Thanks,

                          -Aaron

                          • 10. Re: Passing CF variables in soap request
                            Emily LaMunyon Community Member

                            Thanks again Aaron.

                             

                            I think I understand your question correctly. Yes, I am wanting to make the second API call with the results (session key) obtained from the first API call. I need to obtain this session key and use it in subsequest API calls in order to get documents.

                             

                            I am not sure how to answer this: <cfloop from="1" to="#arraylen(responseNodes)#" index="i"> 2nd_API_call_in_here </cfloop> ?

                             

                            I was hoping to store the Session Key as a variable and use it to make my next call.

                             

                            <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>

                                     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                         <soapenv:Body>

                                             <GetUserId xmlns="http://www.siretechnologies.com/">

                                             <SessionKey>#SesKey#</SessionKey>

                                              <UserName>survweb</UserName>

                                             </GetUserId>

                                           </soapenv:Body>

                                      </soapenv:Envelope>

                                </cfsavecontent>

                             

                            Sorry I am so new to CF ...

                             

                            Let me know if you need more info.

                            • 11. Re: Passing CF variables in soap request
                              itisdesign CommunityMVP

                              Hi Emily,

                               

                              No problem at all, and you're welcome.  The cfloop may be unnecessary.  Could you please try this?

                               

                              <cfset responseNodes = xmlSearch(MyXml,"//*[ local-name() = 'LoginResult' ]")>

                              <cfif arrayLen(responseNodes)>

                                <cfset SesKey = responseNodes[1].XmlText>

                                <!--- GETUserId, Next call to API--->

                                <cfset wsdl_url="http://someurl/sire.asmx?wsdl">

                                <!--- Compose SOAP message to send to Web Service--->

                                <cfxml variable="soap">

                                <cfoutput>

                                <?xml version="1.0" encoding="UTF-8" ?>

                                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                  <soapenv:Body>

                                    <GetUserId xmlns="http://www.siretechnologies.com/">

                                      <SessionKey>#SesKey#</SessionKey>

                                      <UserName>survweb</UserName>

                                    </GetUserId>

                                  </soapenv:Body>

                                </soapenv:Envelope>

                                </cfoutput>

                                </cfxml>

                              </cfif>

                               

                              Thanks,

                              -Aaron

                              • 12. Re: Passing CF variables in soap request
                                BKBK CommunityMVP

                                If there is no need for a loop, then you could just do:

                                 

                                <cfset sesKey = responseNodes[1].LoginResponse.LoginResult.XmlText>

                                <b>SesKey:</b> #sesKey#<br>

                                 

                                However, I can think of one case where the loop is necessary. For example, if the possibility exists that the code will generate more than one value of LoginResult.Xmltext. If so, you may need to validate the value of the session key. For example, by ruling out empty strings. Something like this:

                                 

                                <cfset sessionKey = arrayNew(1)>

                                <cfloop from="1" to="#arraylen(responseNodes)#" index="i">

                                    <cfset sessionKey[i] = responseNodes[i].LoginResponse.LoginResult.XmlText>

                                 

                                    <!--- Validation assumed here is: length of session key > 0. Then set the first non-empty string as session key, and exit the loop --->

                                    <cfif trim(sessionKey[i]) is not "">

                                        <cfset sesKey = sessionKey[i]>

                                        <b>SessionKey:</b> #SesKey#<br>

                                        <cfbreak>

                                    </cfif>

                                </cfloop>

                                 

                                <!--- GETFILEPDF --->

                                 

                                <cfset wsdl_url2="http://slcsireapp-tst/sirewebsvc/sire.asmx?wsdl">

                                <!--- Compose SOAP message to send to Web Service--->

                                 

                                <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>

                                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                     <soapenv:Body>

                                         <GetUserId xmlns="http://www.siretechnologies.com/">

                                         <SessionKey>#sesKey#</SessionKey>

                                          <UserName>survweb</UserName>

                                         </GetUserId>

                                       </soapenv:Body>

                                  </soapenv:Envelope>

                                </cfsavecontent>

                                • 13. Re: Passing CF variables in soap request
                                  Emily LaMunyon Community Member

                                  ERROR.gifHi Aaron,

                                   

                                  You are awesome! It makes sense to not use cfloop. I tried your code and am getting the attached error on this line <cfset UserIdXml  = XmlParse(cfhttp.fileContent)> .

                                  It seems to be getting somewhere though, maybe I mistyped something. Here is my full code:

                                   

                                  <!--- WSDL --->

                                  <cfset wsdl_url="http://someurl/sirewebsvc/sire.asmx?wsdl">

                                   

                                  <!--- Compose SOAP message to send to Web Service--->

                                      <cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8" ?>

                                           <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                               <soapenv:Body>

                                                   <Login xmlns="http://www.siretechnologies.com/">

                                        <LicenseKey>licenseKey</LicenseKey>

                                        <Username>survweb</Username>

                                        <Password>survweb</Password>

                                        <LicenseType>2</LicenseType>

                                        <APIKey>API</APIKey>

                                        <SiteKey></SiteKey>

                                        <CryptKey></CryptKey>

                                        <WebOnly>false</WebOnly>

                                      </Login>

                                                </soapenv:Body>

                                            </soapenv:Envelope>

                                      </cfsavecontent>

                                   

                                   

                                          <!--- Invoke web service to send message--->

                                          <cfhttp url="#wsdl_url#" method="post" >

                                              <cfhttpparam type="header" name="content-type" value="text/xml">

                                              <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/Login">

                                              <cfhttpparam type="header" name="content-length" value="#len(soap)#">

                                              <cfhttpparam type="header" name="charset" value="utf-8">

                                              <cfhttpparam type="xml" name="message" value="#trim(soap)#">

                                          </cfhttp>

                                          <p><cfoutput>#xmlFormat(cfhttp.fileContent)#</cfoutput> </p>

                                          <cfset MyXml = XmlParse(cfhttp.fileContent)>

                                   

                                          <cfdump var="#MyXml#">

                                   

                                   

                                   

                                   

                                   

                                   

                                   

                                   

                                   

                                  <cfset responseNodes = xmlSearch(MyXml,"//*[ local-name() = 'LoginResult' ]")>

                                  <cfif arrayLen(responseNodes)>

                                    <cfset SesKey = responseNodes[1].XmlText>

                                   

                                    <!--- GETUserId, Next call to API--->

                                    <cfset wsdl_url="http://slcsireapp-tst/sire.asmx?wsdl">

                                    <!--- Compose SOAP message to send to Web Service--->

                                    <cfxml variable="soap">

                                    <cfoutput>

                                    <?xml version="1.0" encoding="UTF-8" ?>

                                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                      <soapenv:Body>

                                        <GetUserId xmlns="http://www.siretechnologies.com/">

                                          <SessionKey>#SesKey#</SessionKey>

                                          <UserName>survweb</UserName>

                                        </GetUserId>

                                      </soapenv:Body>

                                    </soapenv:Envelope>

                                    </cfoutput>

                                    </cfxml>

                                  </cfif>

                                   

                                          <!--- Invoke web service to send message--->

                                          <cfhttp url="#wsdl_url#" method="post" >

                                              <cfhttpparam type="header" name="content-type" value="text/xml">

                                              <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/GetUserId">

                                              <cfhttpparam type="header" name="content-length" value="#len(soap)#">

                                              <cfhttpparam type="header" name="charset" value="utf-8">

                                              <cfhttpparam type="xml" name="message" value="#trim(soap)#">

                                          </cfhttp>

                                          <p><cfoutput>#xmlFormat(cfhttp.fileContent)#</cfoutput> </p>

                                        <cfset UserIdXml  = XmlParse(cfhttp.fileContent)>

                                   

                                          <cfdump var="#UserIdXml#">

                                   

                                      <cfset responseNodesUser = xmlSearch(UserIdXml,"//*[ local-name() = 'GetUserIdResponse' ]")>

                                     <cfdump var="#responseNodesUser#">

                                  • 14. Re: Passing CF variables in soap request
                                    Aaron Neff

                                    Hi Emily,

                                     

                                    Thank you, and I don't mind if you unmark my response as the answer.  Reed and BKBK have also provided valid answers.  Without the API key, login info, etc (which understandably you would not post in a public forum) we can only guess as to what the API should be returning and what it is actually returning.  Example: you may or may not need the cfloop. 

                                     

                                    As for 'UserIdXml = XmlParse(cfhttp.fileContent)' throwing an 'error occured while Parsing an XML document', that is b/c the 2nd cfhttp call is not returning XML for some reason.

                                     

                                    (side note: Adobe, that should be "occurred" not "occured".)

                                     

                                    Could you please try this, and let us know what the output is?

                                     

                                    <!--- WSDL --->

                                     

                                    <cfset wsdl_url="http://someurl/sirewebsvc/sire.asmx?wsdl">

                                     

                                    <!--- Compose SOAP message to send to Web Service--->

                                     

                                    <cfxml variable="soap">

                                    <?xml version="1.0" encoding="UTF-8" ?>

                                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                      <soapenv:Body>

                                        <Login xmlns="http://www.siretechnologies.com/">

                                          <LicenseKey>licenseKey</LicenseKey>

                                          <Username>survweb</Username>

                                          <Password>survweb</Password>

                                          <LicenseType>2</LicenseType>

                                          <APIKey>API</APIKey>

                                          <SiteKey></SiteKey>

                                          <CryptKey></CryptKey>

                                          <WebOnly>false</WebOnly>

                                        </Login>

                                      </soapenv:Body>

                                    </soapenv:Envelope>

                                    </cfxml>

                                     

                                    <!--- Invoke web service to send message--->

                                     

                                    <cfhttp url="#wsdl_url#" method="post" >

                                    <cfhttpparam type="header" name="content-type" value="text/xml">

                                    <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/Login">

                                    <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#">

                                    <cfhttpparam type="header" name="charset" value="utf-8">

                                    <cfhttpparam type="xml" name="message" value="#trim(soap)#">

                                    </cfhttp>

                                     

                                    <cfif isXML(cfhttp.fileContent)>

                                      <cfset MyXml = XmlParse(cfhttp.fileContent)>

                                      <cfset responseNodes = xmlSearch(MyXml,"//*[ local-name() = 'LoginResult' ]")>

                                      <cfif arrayLen(responseNodes)>

                                        <cfset SesKey = responseNodes[1].XmlText>

                                       

                                        <!--- GETUserId, Next call to API--->

                                       

                                        <cfset wsdl_url="http://slcsireapp-tst/sire.asmx?wsdl">

                                       

                                        <!--- Compose SOAP message to send to Web Service--->

                                       

                                        <cfxml variable="soap">

                                        <cfoutput>

                                        <?xml version="1.0" encoding="UTF-8" ?>

                                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                          <soapenv:Body>

                                            <GetUserId xmlns="http://www.siretechnologies.com/">

                                              <SessionKey>#SesKey#</SessionKey>

                                              <UserName>survweb</UserName>

                                            </GetUserId>

                                          </soapenv:Body>

                                        </soapenv:Envelope>

                                        </cfoutput>

                                        </cfxml>

                                      </cfif>

                                     

                                      <!--- Invoke web service to send message--->

                                     

                                      <cfhttp url="#wsdl_url#" method="post" >

                                      <cfhttpparam type="header" name="content-type" value="text/xml">

                                      <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/GetUserId">

                                      <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#">

                                      <cfhttpparam type="header" name="charset" value="utf-8">

                                      <cfhttpparam type="xml" name="message" value="#trim(soap)#">

                                      </cfhttp>

                                      <cfif isXML(cfhttp.fileContent)>

                                        <cfset UserIdXml  = XmlParse(cfhttp.fileContent)>

                                        <cfset responseNodesUser = xmlSearch(UserIdXml,"//*[ local-name() = 'GetUserIdResponse' ]")>

                                       

                                        <cfdump var="#responseNodesUser#" />

                                       

                                        <cfelse>

                                        2nd API call did not return XML

                                       

                                        <cfdump var="#cfhttp.fileContent#" />

                                       

                                      </cfif>

                                      <cfelse>

                                      1st API call did not return XML

                                    </cfif>

                                     

                                    Thanks!,

                                    -Aaron

                                    • 15. Re: Passing CF variables in soap request
                                      Emily LaMunyon Community Member

                                      You are the best Aaron! I will mark everyone who helped.

                                       

                                      When I run the script you provided with the credentials needed. I get a page that reads:

                                       

                                      "1st API call did not return XML"

                                       

                                      Also I am not getting any other errors.

                                       

                                      Thanks!!!

                                      • 16. Re: Passing CF variables in soap request
                                        Aaron Neff Community Member

                                        Emily LaMunyon wrote:

                                         

                                        When I run the script you provided with the credentials needed. I get a page that reads:

                                         

                                        "1st API call did not return XML"

                                         

                                        Also I am not getting any other errors.

                                        Hi Emily,

                                         

                                        You're welcome, and that message indicates that the 1st call doesn't even return properly.  So we can disregard the 2nd call for the time being.  Could you try this, and let us know what the output is?

                                         

                                        <!--- WSDL --->

                                        <cfset wsdl_url="http://someurl/sirewebsvc/sire.asmx?wsdl">

                                        <!--- Compose SOAP message to send to Web Service--->

                                        <cfxml variable="soap">

                                        <?xml version="1.0" encoding="UTF-8" ?>

                                        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                          <soapenv:Body>

                                            <Login xmlns="http://www.siretechnologies.com/">

                                              <LicenseKey>licenseKey</LicenseKey>

                                              <Username>survweb</Username>

                                              <Password>survweb</Password>

                                              <LicenseType>2</LicenseType>

                                              <APIKey>API</APIKey>

                                              <SiteKey></SiteKey>

                                              <CryptKey></CryptKey>

                                              <WebOnly>false</WebOnly>

                                            </Login>

                                          </soapenv:Body>

                                        </soapenv:Envelope>

                                        </cfxml>

                                        <!--- Invoke web service to send message--->

                                        <cfhttp url="#wsdl_url#" method="post" >

                                        <cfhttpparam type="header" name="content-type" value="text/xml">

                                        <cfhttpparam type="header" name="SOAPAction" value="http://www.siretechnologies.com/Login">

                                        <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#">

                                        <cfhttpparam type="header" name="charset" value="utf-8">

                                        <cfhttpparam type="xml" name="message" value="#trim(soap)#">

                                        </cfhttp>

                                         

                                        <cfdump var="#CFHTTP.FileContent#" />

                                         

                                        Thanks!,

                                        -Aaron

                                        • 17. Re: Passing CF variables in soap request
                                          Emily LaMunyon Community Member

                                          This code seems to be working. I see the output of the login result (session key). Would it help to have the credentials for the API?

                                           

                                          XML.gif

                                          • 18. Re: Passing CF variables in soap request
                                            Emily LaMunyon Community Member

                                            Okay, I am sorry to tell you this, but when I run the second to last script you provided, I now get "2nd API  Call did not return XML. I am not sure why it did not work the first time, but I refreshed my browser and ran it again and this is what I see.XML2.gif

                                            • 19. Re: Passing CF variables in soap request
                                              itisdesign CommunityMVP

                                              Emily LaMunyon wrote:

                                               

                                              Okay, I am sorry to tell you this, but when I run the second to last script you provided, I now get "2nd API  Call did not return XML. I am not sure why it did not work the first time, but I refreshed my browser and ran it again and this is what I see.

                                               

                                              Hi Emily,

                                               

                                              Not a problem.  And that error is a 404 stating that /sire.asmx doesn't exist at whatever domain was specified when making the call.  Is it http://www.siretechnologies.com/sire.asmx?  When I access that, I get a 404.  API credentials may help later (thanks for asking), but for now we just need to know what the correct URL for the 2nd call is.  Is there online documentation for this call that is publicly-viewable?

                                               

                                              Thanks,

                                              -Aaron

                                              • 20. Re: Passing CF variables in soap request
                                                Emily LaMunyon Community Member

                                                The API is installed on an internal server in my department. I am sorry this is internal, not sure if that will make this impossible. The address is http://slcsireapp-tst/sire.asmx?wsdl.

                                                 

                                                <!--- GETUserId, Next call to API--->

                                                 

                                                  

                                                 

                                                   <cfset wsdl_url="http://slcsireapp-tst/sire.asmx?wsdl">

                                                 

                                                  

                                                 

                                                    <!--- Compose SOAP message to send to Web Service--->

                                                 

                                                  

                                                 

                                                    <cfxml variable="soap">

                                                 

                                                    <cfoutput>

                                                 

                                                    <?xml version="1.0" encoding="UTF-8" ?>

                                                 

                                                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                                 

                                                      <soapenv:Body>

                                                 

                                                        <GetUserId xmlns="http://www.siretechnologies.com/">

                                                 

                                                          <SessionKey>#SesKey#</SessionKey>

                                                 

                                                          <UserName>survweb</UserName>

                                                 

                                                        </GetUserId>

                                                 

                                                      </soapenv:Body>

                                                 

                                                    </soapenv:Envelope>

                                                 

                                                    </cfoutput>

                                                 

                                                    </cfxml>

                                                 

                                                  </cfif>

                                                 

                                                Here is a screenshot of the Second API Call, and what it is expecting from SOAP.. I am afriad there is no public documentation for this call.

                                                 

                                                2nd_API_Call_Soap.gif

                                                • 21. Re: Passing CF variables in soap request
                                                  Emily LaMunyon Community Member

                                                  Oh my gosh Aaron, I think I just got it to work. You were right, the URL in that calls the API was wrong.

                                                   

                                                  I am sooo sorry to waste your time. I think the code you provided is working. This is the return I am getting. The 1060 is the userid I was after with the session key. I need to make yet another call to the API using this information, so in essence I can follow the code I have and recreate it for the next call, correct?

                                                   

                                                  You have been a tremendous help!!!!

                                                   

                                                  solution.gif

                                                  • 22. Re: Passing CF variables in soap request
                                                    itisdesign CommunityMVP

                                                    Emily LaMunyon wrote:

                                                     

                                                    Oh my gosh Aaron, I think I just got it to work. You were right, the URL in that calls the API was wrong.

                                                     

                                                    I am sooo sorry to waste your time. I think the code you provided is working. This is the return I am getting. The 1060 is the userid I was after with the session key. I need to make yet another call to the API using this information, so in essence I can follow the code I have and recreate it for the next call, correct?

                                                     

                                                    Awesome and thanks   I was just about to post a copy of that code w/ the URL changed, to see if it'd work.  Yes, you can follow the same code you have.  BUT, I did find a copy of the API at http://209.6.162.132/SIREWebSvc/sire.asmx  I'm going to follow-up w/ another example for you to try which might be even easier.  Oh, and Reed helped on this thread too btw.

                                                     

                                                    I'll follow-up.

                                                     

                                                    Thanks!,

                                                    -Aaron

                                                    • 23. Re: Passing CF variables in soap request
                                                      Emily LaMunyon Community Member

                                                      Thanks Reed as well!!!

                                                       

                                                      Yes , the Sire link you provided is exactly what I am coding against in order to finally make the GETFilePDF call. That is the one I am trying to get to in order to pull a pdf document. I have to make two API calls, Login, GetUserId, and then I can enter the credentials for GetFielPDF.

                                                       

                                                      Have a great weekend!!!

                                                      • 24. Re: Passing CF variables in soap request
                                                        itisdesign CommunityMVP

                                                        Emily LaMunyon wrote:

                                                         

                                                        Yes , the Sire link you provided is exactly what I am coding against in order to finally make the GETFilePDF call. That is the one I am trying to get to in order to pull a pdf document. I have to make two API calls, Login, GetUserId, and then I can enter the credentials for GetFielPDF.

                                                         

                                                        Have a great weekend!!!

                                                        Hi Emily,

                                                         

                                                        Could you please try this?  Just enter your credential information at the top, and then it should create a file named 'PDFFromAPI.pdf' in the same directory as your script.  If it doesn't, we'll get it sorted.  But based on the API doc I saw, you shouldn't have to use SOAP.  If the file isn't created, just let me know what the result was.

                                                         

                                                        <cfscript>

                                                          apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";

                                                          licenseKey = "license_key_here";

                                                          username = "survweb";

                                                          password = "password_here";

                                                          licenseType = 2;

                                                          apiKey = "api_key_here";

                                                          siteKey = "site_key_here";

                                                          cryptKey = "crypt_key_here";

                                                          webOnly = false;

                                                          pdfDestination = expandPath("./PDFFromAPI.pdf");

                                                        </cfscript>

                                                        <!--- Get Session Key --->

                                                        <cfhttp url="#apiURLBase#/Login?LicenseKey=#licenseKey#&Username=#username#&Password=#password#&L icenseType=#licenseType#&APIKey=#apiKey#&SiteKey=#siteKey#&CryptKey=#cryptKey#&WebOnly=#we bOnly# HTTP/1.1" />

                                                        <cfif isXML(CFHTTP.FileContent)>

                                                          <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                          <cfset sessionKey = responseXML.xmlRoot.xmlText />

                                                          <cfelse>

                                                          <p>1st API call did not return valid XML</p>

                                                        </cfif>

                                                        <!--- Get User ID --->

                                                        <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                          <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#sessionKey#&Username=#username# HTTP/1.1" />

                                                          <cfif isXML(CFHTTP.FileContent)>

                                                            <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                            <cfset userID = responseXML.xmlRoot.xmlText />

                                                            <cfelse>

                                                            <p>2nd API call did not return valid XML</p>

                                                          </cfif>

                                                          <cfelse>

                                                          <p>1st API call did not return a valid value</p>

                                                        </cfif>

                                                        <!--- Get PDF File --->

                                                        <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                          <cfset cabinetName = "cabinet_name_here" />

                                                          <cfset fileID = "file_ID_here" />

                                                          <cfset tifOnly = false /><!--- or true --->

                                                          <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#sessionKey#&CabinetName=#cabinetName#&FileId=#fi leID#&TIFOnly=#tifOnly#&UserId=#userID# HTTP/1.1" />

                                                          <cfif isXML(CFHTTP.FileContent)>

                                                            <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                            <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />

                                                            <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->

                                                            <cfif !(len(pdfBinaryBase64) % 4)>

                                                              <cftry>

                                                                <!--- Save PDF file --->

                                                                <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />

                                                                <cfcatch type="any"></cfcatch>

                                                              </cftry>

                                                            </cfif>

                                                            <cfelse>

                                                            <p>3rd API call did not return valid XML</p>

                                                          </cfif>

                                                          <cfelse>

                                                          <p>2nd API call did not return a valid value</p>

                                                        </cfif>

                                                         

                                                        Have a great weekend yourself!,

                                                        -Aaron

                                                        • 25. Re: Passing CF variables in soap request
                                                          Emily LaMunyon Community Member

                                                          Thanks so much again guys, this looks like it will do the trick. I plugged in my credentials and am getting the following.

                                                           

                                                          ERROR.gif

                                                           

                                                          It may have to do with my license key, I was having problems with it before using this http post method. The license key is ##W3b5vc|<3y##, and in the soap request I had to escape the < character and use ##W3b5vc|&lt;3y## instead. I have tried both in the code you provided and still get the same result as above. Do you think this could be causing problems? Here is the code I used, maybe I missed something.

                                                           

                                                          <cfscript>

                                                            apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";

                                                            licenseKey = "##W3b5vc|<3y##";

                                                            username = "survweb";

                                                            password = "survweb";

                                                            licenseType = 2;

                                                            apiKey = "api";

                                                            siteKey = "";

                                                            cryptKey = "";

                                                            webOnly = false;

                                                            pdfDestination = expandPath("./PDFFromAPI.pdf");

                                                          </cfscript>

                                                          <!--- Get Session Key --->

                                                          <cfhttp url="#apiURLBase#/Login?LicenseKey=#licenseKey#&Username=#username#&Password=#password#&L icenseType=#licenseType#&APIKey=#apiKey#&SiteKey=#siteKey#&CryptKey=#cryptKey#&WebOnly=#we bOnly# HTTP/1.1" />

                                                          <cfif isXML(CFHTTP.FileContent)>

                                                            <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                            <cfset sessionKey = responseXML.xmlRoot.xmlText />

                                                            <cfelse>

                                                            <p>1st API call did not return valid XML</p>

                                                          </cfif>

                                                          <!--- Get User ID --->

                                                          <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                            <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#sessionKey#&Username=#username# HTTP/1.1" />

                                                            <cfif isXML(CFHTTP.FileContent)>

                                                              <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                              <cfset userID = responseXML.xmlRoot.xmlText />

                                                              <cfelse>

                                                              <p>2nd API call did not return valid XML</p>

                                                            </cfif>

                                                            <cfelse>

                                                            <p>1st API call did not return a valid value</p>

                                                          </cfif>

                                                          <!--- Get PDF File --->

                                                          <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                            <cfset cabinetName = "Surveys" />

                                                            <cfset fileID = "105684" />

                                                            <cfset tifOnly = false /><!--- or true --->

                                                            <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#sessionKey#&CabinetName=#cabinetName#&FileId=#fi leID#&TIFOnly=#tifOnly#&UserId=#userID# HTTP/1.1" />

                                                            <cfif isXML(CFHTTP.FileContent)>

                                                              <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                              <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />

                                                              <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->

                                                              <cfif !(len(pdfBinaryBase64) % 4)>

                                                                <cftry>

                                                                  <!--- Save PDF file --->

                                                                  <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />

                                                                  <cfcatch type="any"></cfcatch>

                                                                </cftry>

                                                              </cfif>

                                                              <cfelse>

                                                              <p>3rd API call did not return valid XML</p>

                                                            </cfif>

                                                            <cfelse>

                                                            <p>2nd API call did not return a valid value</p>

                                                          </cfif>

                                                          • 26. Re: Passing CF variables in soap request
                                                            itisdesign CommunityMVP

                                                            Emily LaMunyon wrote:

                                                             

                                                            I plugged in my credentials and am getting the following.

                                                            Hi Emily,

                                                             

                                                            I had a mistake at the end of the URL strings.  Could you please try this and let me know the result?

                                                             

                                                            <cfscript>
                                                              apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";
                                                              licenseKey = "##W3b5vc|<3y##";
                                                              username = "survweb";
                                                              password = "survweb";
                                                              licenseType = 2;
                                                              apiKey = "api";
                                                              siteKey = "";
                                                              cryptKey = "";
                                                              webOnly = false;
                                                              pdfDestination = expandPath("./PDFFromAPI.pdf");
                                                            </cfscript>

                                                            <!--- Get Session Key --->
                                                            <cfhttp url="#apiURLBase#/Login?LicenseKey=#licenseKey#&Username=#username#&Password=#password#&L icenseType=#licenseType#&APIKey=#apiKey#&SiteKey=#siteKey#&CryptKey=#cryptKey#&WebOnly=#we bOnly#" />

                                                            <cfif isXML(CFHTTP.FileContent)>
                                                              <cfset responseXML = xmlParse(CFHTTP.FileContent) />
                                                              <cfset sessionKey = responseXML.xmlRoot.xmlText />
                                                              <cfelse>
                                                              <p>1st API call did not return valid XML</p>
                                                              <cfoutput>#CFHTTP.FileContent#</cfoutput>
                                                              <cfabort />
                                                            </cfif>

                                                            <!--- Get User ID --->
                                                            <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>
                                                              <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#sessionKey#&Username=#username#" />
                                                              <cfif isXML(CFHTTP.FileContent)>
                                                                <cfset responseXML = xmlParse(CFHTTP.FileContent) />
                                                                <cfset userID = responseXML.xmlRoot.xmlText />
                                                                <cfelse>
                                                                <p>2nd API call did not return valid XML</p>
                                                                <cfoutput>#CFHTTP.FileContent#</cfoutput>
                                                                <cfabort />
                                                              </cfif>
                                                              <cfelse>
                                                              <p>1st API call did not return a valid value</p>
                                                            </cfif>

                                                            <!--- Get PDF File --->
                                                            <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>
                                                              <cfset cabinetName = "Surveys" />
                                                              <cfset fileID = "105684" />
                                                              <cfset tifOnly = false />
                                                              <!--- or true --->
                                                              <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#sessionKey#&CabinetName=#cabinetName#&FileId=#fi leID#&TIFOnly=#tifOnly#&UserId=#userID#" />
                                                              <cfif isXML(CFHTTP.FileContent)>
                                                                <cfset responseXML = xmlParse(CFHTTP.FileContent) />
                                                                <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />
                                                                <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->
                                                                <cfif !(len(pdfBinaryBase64) % 4)>
                                                                  <cftry>
                                                                    <!--- Save PDF file --->
                                                                    <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />
                                                                    <cfcatch type="any">
                                                                    </cfcatch>
                                                                  </cftry>
                                                                </cfif>
                                                                <cfelse>
                                                                <p>3rd API call did not return valid XML</p>
                                                                <cfoutput>#CFHTTP.FileContent#</cfoutput>
                                                                <cfabort />
                                                              </cfif>
                                                              <cfelse>
                                                              <p>2nd API call did not return a valid value</p>
                                                            </cfif>

                                                             

                                                            Thanks!,

                                                            -Aaron

                                                            • 27. Re: Passing CF variables in soap request
                                                              Emily LaMunyon Community Member

                                                              Hey Aaron,

                                                               

                                                              Okay, I think we are getting closer. I am now getting the following error. I checked the username and it is correct, survweb.

                                                               

                                                              ERROR.gif

                                                               

                                                               

                                                              <cfscript>

                                                                apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";

                                                                licenseKey = "##W3b5vc|<3y##";

                                                                username = "survweb";

                                                                password = "survweb";

                                                                licenseType = 2;

                                                                apiKey = "AP1";

                                                                siteKey = "";

                                                                cryptKey = "";

                                                                webOnly = false;

                                                                pdfDestination = expandPath("./PDFFromAPI.pdf");

                                                              </cfscript>

                                                              <!--- Get Session Key --->

                                                              <cfhttp url="#apiURLBase#/Login?LicenseKey=#licenseKey#&Username=#username#&Password=#password#&L icenseType=#licenseType#&APIKey=#apiKey#&SiteKey=#siteKey#&CryptKey=#cryptKey#&WebOnly=#we bOnly#" />

                                                              <cfif isXML(CFHTTP.FileContent)>

                                                                <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                <cfset sessionKey = responseXML.xmlRoot.xmlText />

                                                                <cfelse>

                                                                <p>1st API call did not return valid XML</p>

                                                                <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                <cfabort />

                                                              </cfif>

                                                              <!--- Get User ID --->

                                                              <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                                <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#sessionKey#&Username=#username#" />

                                                                <cfif isXML(CFHTTP.FileContent)>

                                                                  <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                  <cfset userID = responseXML.xmlRoot.xmlText />

                                                                  <cfelse>

                                                                  <p>2nd API call did not return valid XML</p>

                                                                  <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                  <cfabort />

                                                                </cfif>

                                                                <cfelse>

                                                                <p>1st API call did not return a valid value</p>

                                                              </cfif>

                                                              <!--- Get PDF File --->

                                                              <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                                <cfset cabinetName = "Surveys" />

                                                                <cfset fileID = "105684" />

                                                                <cfset tifOnly = false />

                                                                <!--- or true --->

                                                                <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#sessionKey#&CabinetName=#cabinetName#&FileId=#fi leID#&TIFOnly=#tifOnly#&UserId=#userID#" />

                                                                <cfif isXML(CFHTTP.FileContent)>

                                                                  <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                  <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />

                                                                  <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->

                                                                  <cfif !(len(pdfBinaryBase64) % 4)>

                                                                    <cftry>

                                                                      <!--- Save PDF file --->

                                                                      <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />

                                                                      <cfcatch type="any">

                                                                      </cfcatch>

                                                                    </cftry>

                                                                  </cfif>

                                                                  <cfelse>

                                                                  <p>3rd API call did not return valid XML</p>

                                                                  <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                  <cfabort />

                                                                </cfif>

                                                                <cfelse>

                                                                <p>2nd API call did not return a valid value</p>

                                                              </cfif>

                                                              • 28. Re: Passing CF variables in soap request
                                                                itisdesign CommunityMVP

                                                                Hi Emily,

                                                                 

                                                                Yes, we're getting closer!  Could you please try this?  I updated the URL attribute of the 3 cfhttp tags (using CF9 syntax, as it appears you're on CF9?).

                                                                 

                                                                <cfscript>

                                                                  apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";

                                                                  licenseKey = "##W3b5vc|<3y##";

                                                                  username = "survweb";

                                                                  password = "survweb";

                                                                  licenseType = 2;

                                                                  apiKey = "api";

                                                                  siteKey = "";

                                                                  cryptKey = "";

                                                                  webOnly = false;

                                                                  pdfDestination = expandPath("./PDFFromAPI.pdf");

                                                                </cfscript>

                                                                 

                                                                <!--- Get Session Key --->

                                                                <cfhttp url="#apiURLBase#/Login?LicenseKey=#urlEncodedFormat(licenseKey)#&Username=#urlEncodedFor mat(username)#&Password=#urlEncodedFormat(password)#&LicenseType=#urlEncodedFormat(license Type)#&APIKey=#urlEncodedFormat(apiKey)#&SiteKey=#urlEncodedFormat(siteKey)#&CryptKey=#url EncodedFormat(cryptKey)#&WebOnly=#urlEncodedFormat(webOnly)#" />

                                                                 

                                                                <cfif isXML(CFHTTP.FileContent)>

                                                                  <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                  <cfset sessionKey = responseXML.xmlRoot.xmlText />

                                                                  <cfelse>

                                                                  <p>1st API call did not return valid XML</p>

                                                                  <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                  <cfabort />

                                                                </cfif>

                                                                 

                                                                <!--- Get User ID --->

                                                                <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                                  <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#urlEncodedFormat(sessionKey)#&Username=#urlEncode dFormat(username)#" />

                                                                  <cfif isXML(CFHTTP.FileContent)>

                                                                    <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                    <cfset userID = responseXML.xmlRoot.xmlText />

                                                                    <cfelse>

                                                                    <p>2nd API call did not return valid XML</p>

                                                                    <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                    <cfabort />

                                                                  </cfif>

                                                                  <cfelse>

                                                                  <p>1st API call did not return a valid value</p>

                                                                </cfif>

                                                                 

                                                                <!--- Get PDF File --->

                                                                <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                                  <cfset cabinetName = "Surveys" />

                                                                  <cfset fileID = "105684" />

                                                                  <cfset tifOnly = false />

                                                                  <!--- or true --->

                                                                  <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#urlEncodedFormat(sessionKey)#&CabinetName=#urlEn codedFormat(cabinetName)#&FileId=#urlEncodedFormat(fileID)#&TIFOnly=#urlEncodedFormat(tifO nly)#&UserId=#urlEncodedFormat(userID)#" />

                                                                  <cfif isXML(CFHTTP.FileContent)>

                                                                    <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                    <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />

                                                                    <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->

                                                                    <cfif !(len(pdfBinaryBase64) % 4)>

                                                                      <cftry>

                                                                        <!--- Save PDF file --->

                                                                        <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />

                                                                        <cfcatch type="any">

                                                                        </cfcatch>

                                                                      </cftry>

                                                                    </cfif>

                                                                    <cfelse>

                                                                    <p>3rd API call did not return valid XML</p>

                                                                    <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                    <cfabort />

                                                                  </cfif>

                                                                  <cfelse>

                                                                  <p>2nd API call did not return a valid value</p>

                                                                </cfif>

                                                                 

                                                                Thanks,

                                                                -Aaron

                                                                • 29. Re: Passing CF variables in soap request
                                                                  Emily LaMunyon Community Member

                                                                  I think this one is the closest so far. Now I am getting an error concerning my license key. I have tried both ##W3b5vc|&lt;3y## and ##W3b5vc|<3y## in this new script. Does anything about this license key string seem like it would not work? I asked Sire about changing it and they said it was hard-coded so it is not possible. Any ideas?

                                                                   

                                                                  Thanks a trillion!!!

                                                                   

                                                                  ERROR.gif

                                                                  • 30. Re: Passing CF variables in soap request
                                                                    itisdesign CommunityMVP

                                                                    Emily LaMunyon wrote:

                                                                     

                                                                    ##W3b5vc|<3y##

                                                                    Hi Emily,

                                                                     

                                                                    Did they provide you with ##W3b5vc|<3y## or with #W3b5vc|<3y#  ?

                                                                     

                                                                    Meaning, two or one # at both ends?

                                                                     

                                                                    Thanks,

                                                                    -Aaron

                                                                    • 31. Re: Passing CF variables in soap request
                                                                      Emily LaMunyon Community Member

                                                                      This is the original license key they provided me, two # on each end.

                                                                       

                                                                      ##W3b5vc|<3y##

                                                                       

                                                                      I was able to get ##W3b5vc|&lt;3y## to work with soap, replacing the < with &lt; and it seemed okay. Not sure why cfhttp doesn’t like either of the license keys.

                                                                       

                                                                      I am looking into charsets on cfhttp now, not getting much info though.

                                                                      • 32. Re: Passing CF variables in soap request
                                                                        itisdesign CommunityMVP

                                                                        itisdesign wrote:

                                                                         

                                                                        Emily LaMunyon wrote:

                                                                         

                                                                        ##W3b5vc|<3y##

                                                                        Did they provide you with ##W3b5vc|<3y## or with #W3b5vc|<3y#  ?

                                                                        I'll assume the former (w/ 2 # at both sides)..  Could you try this?

                                                                         

                                                                        <cfscript>

                                                                          apiURLBase = "http://slcsireapp-tst/sirewebsvc/sire.asmx";

                                                                          licenseKey = "####W3b5vc|<3y####";//CF converts each ## to # (# is a special character in CF)

                                                                          username = "survweb";

                                                                          password = "survweb";

                                                                          licenseType = 2;

                                                                          apiKey = "api";

                                                                          siteKey = "";

                                                                          cryptKey = "";

                                                                          webOnly = false;

                                                                          pdfDestination = expandPath("./PDFFromAPI.pdf");

                                                                        </cfscript>

                                                                         

                                                                        <!--- Get Session Key --->

                                                                        <cfhttp url="#apiURLBase#/Login?LicenseKey=#urlEncodedFormat(licenseKey)#&Username=#urlEncodedFor mat(username)#&Password=#urlEncodedFormat(password)#&LicenseType=#urlEncodedFormat(license Type)#&APIKey=#urlEncodedFormat(apiKey)#&SiteKey=#urlEncodedFormat(siteKey)#&CryptKey=#url EncodedFormat(cryptKey)#&WebOnly=#urlEncodedFormat(webOnly)#" />

                                                                         

                                                                        <cfif isXML(CFHTTP.FileContent)>

                                                                          <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                          <cfset sessionKey = responseXML.xmlRoot.xmlText />

                                                                          <cfelse>

                                                                          <p>1st API call did not return valid XML</p>

                                                                          <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                          <cfabort />

                                                                        </cfif>

                                                                         

                                                                        <!--- Get User ID --->

                                                                        <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                                          <cfhttp url="#apiURLBase#/GetUserId?SessionKey=#urlEncodedFormat(sessionKey)#&Username=#urlEncode dFormat(username)#" />

                                                                          <cfif isXML(CFHTTP.FileContent)>

                                                                            <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                            <cfset userID = responseXML.xmlRoot.xmlText />

                                                                            <cfelse>

                                                                            <p>2nd API call did not return valid XML</p>

                                                                            <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                            <cfabort />

                                                                          </cfif>

                                                                          <cfelse>

                                                                          <p>1st API call did not return a valid value</p>

                                                                        </cfif>

                                                                         

                                                                        <!--- Get PDF File --->

                                                                        <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                                          <cfset cabinetName = "Surveys" />

                                                                          <cfset fileID = "105684" />

                                                                          <cfset tifOnly = false />

                                                                          <!--- or true --->

                                                                          <cfhttp url="#apiURLBase#/GetFilePDF?SessionKey=#urlEncodedFormat(sessionKey)#&CabinetName=#urlEn codedFormat(cabinetName)#&FileId=#urlEncodedFormat(fileID)#&TIFOnly=#urlEncodedFormat(tifO nly)#&UserId=#urlEncodedFormat(userID)#" />

                                                                          <cfif isXML(CFHTTP.FileContent)>

                                                                            <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                            <cfset pdfBinaryBase64 = responseXML.xmlRoot.xmlText />

                                                                            <!--- CF does not have an isBase64() function. The mod 4 check and the try/catch are workarounds for this. --->

                                                                            <cfif !(len(pdfBinaryBase64) % 4)>

                                                                              <cftry>

                                                                                <!--- Save PDF file --->

                                                                                <cffile action="write" file="#pdfDestination#" output="#binaryDecode(pdfBinaryBase64, 'base64')#" />

                                                                                <cfcatch type="any">

                                                                                </cfcatch>

                                                                              </cftry>

                                                                            </cfif>

                                                                            <cfelse>

                                                                            <p>3rd API call did not return valid XML</p>

                                                                            <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                            <cfabort />

                                                                          </cfif>

                                                                          <cfelse>

                                                                          <p>2nd API call did not return a valid value</p>

                                                                        </cfif>

                                                                         

                                                                        Oh and you're welcome btw.

                                                                         

                                                                        Thanks!,

                                                                        -Aaron

                                                                        • 33. Re: Passing CF variables in soap request
                                                                          itisdesign CommunityMVP

                                                                          Emily LaMunyon wrote:

                                                                           

                                                                          This is the original license key they provided me, two # on each end.

                                                                           

                                                                          ##W3b5vc|<3y##

                                                                           

                                                                          I was able to get ##W3b5vc|&lt;3y## to work with soap, replacing the < with &lt; and it seemed okay. Not sure why cfhttp doesn’t like either of the license keys.

                                                                           

                                                                          I am looking into charsets on cfhttp now, not getting much info though.

                                                                          Hi Emily,

                                                                           

                                                                          I see you just sent this reply right before my last reply.  Very cool, I assumed it should have 2 # on each side in my last example.  So please go ahead and try that last example I posted.  The issue was the #.  And the issue is described in the last example on this doc page about escaping quotation marks and number signs.

                                                                           

                                                                          Thanks,

                                                                          -Aaron

                                                                          • 34. Re: Passing CF variables in soap request
                                                                            Emily LaMunyon Community Member

                                                                            Hi Aaron,

                                                                             

                                                                            The issue with the # signs seems to be solved. I am having problems with the GetFilePDF credentials, even when I test it outside of the code, which is why I think I am getting the following error. I am meeting with Sire on Thursday morning to see why the credentials they provided are not working. I think that is what is behind the Append to PDF error. I will let you know if it works when I get the correct information.

                                                                            You guys have been so beyond kind for your time and effort on this!

                                                                             

                                                                            ERROR.gif

                                                                            • 35. Re: Passing CF variables in soap request
                                                                              itisdesign CommunityMVP

                                                                              Hi Emily,

                                                                               

                                                                              Good to hear the # sign issue is resolved.  I have no idea what it wants for fileID and cabinetName, so hopefully the Sire people will be able to help w/ that.  I'm _guessing_ the issue may be the cabinetName.. perhaps there is a 'tree' of cabinets (like a folder structure) and perhaps the Surveys cabinet is located w/in another cabinet?  As in CabinetName="/path/to/Surveys" or something like that.  Dunno, just guessing.

                                                                               

                                                                              And you're welcome!

                                                                               

                                                                              Thanks,

                                                                              -Aaron

                                                                              • 36. Re: Passing CF variables in soap request
                                                                                BKBK CommunityMVP

                                                                                Apparently, the last isXML(CFHTTP.FileContent) test is false. Processing therefore moves to the cfelse block. My suggestion is to print out and examine the URL of the HTTP call. Something like this:

                                                                                 

                                                                                <cfelse>

                                                                                    <p>3rd API call did not return valid XML</p>

                                                                                <cfoutput>

                                                                                    <p>CFHTTP.FileContent: #CFHTTP.FileContent#</p>

                                                                                    <p>url="#apiURLBase#/GetFilePDF?SessionKey=#urlEncodedFormat(sessionKey) #&CabinetName=#urlEncodedFormat(cabinetName)#&FileId=#urlEncodedFormat  (fileID)#&TIFOnly=#urlEncodedFormat(tifOnly)#&UserId=#urlEncodedFormat (userID)#"</p>

                                                                                </cfoutput>

                                                                                    <cfabort />

                                                                                  </cfif>

                                                                                 

                                                                                Where does the extraneous string "--->" in the error message come from? If it is coming in as part of CFHTTP.FileContent, then it could be pointing to a problem in the called page.

                                                                                • 37. Re: Passing CF variables in soap request
                                                                                  Emily LaMunyon Community Member

                                                                                  Hey guys,

                                                                                   

                                                                                  I solved the problem of the credentials for the GetFilePDF, it turns out that the files weren't even on the server I was testing, so the code could not find them, but they are there now. That part seems to be working. However, I have a couple of other questions.

                                                                                   

                                                                                  First, I forgot that I have to call the Logout method after all of this is finished so I do not tie up a license. I took a stab at it and seem to be having issues, I am getting the error in that block that reads "4th API call did not return valid XML". I think I am close though..any thoughts?

                                                                                   

                                                                                  <!--- Logout --->

                                                                                  <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                                                    <cfhttp url="#apiURLBase#/Logout?SessionKey=#urlEncodedFormat(sessionKey)#"/>

                                                                                    <cfif isXML(CFHTTP.FileContent)>

                                                                                      <cfset responseXML = xmlParse(CFHTTP.FileContent) />

                                                                                      <cfset logout = responseXML.xmlRoot.xmlText />

                                                                                      <cfelse>

                                                                                      <p>4th API call did not return valid XML</p>

                                                                                      <cfoutput>#CFHTTP.FileContent#</cfoutput>

                                                                                      <cfabort />

                                                                                    </cfif>

                                                                                    <cfelse>

                                                                                    <p>1st API call did not return a valid value</p>

                                                                                  </cfif>

                                                                                   

                                                                                   

                                                                                   

                                                                                  Second, I am interested in the ability to have the file_id be dynamic, where the user is able to select the file through a query, instead of having to hard-code it in. Is this pocssible in this scenario?

                                                                                   

                                                                                  Thanks!

                                                                                  • 38. Re: Passing CF variables in soap request
                                                                                    itisdesign CommunityMVP

                                                                                    Emily LaMunyon wrote:

                                                                                     

                                                                                    First, I forgot that I have to call the Logout method

                                                                                    Hi Emily,

                                                                                     

                                                                                    Sorry, the logout response isn't the same format as the others.  It doesn't return an XML response at all.  Instead, it just returns an HTTP status code.  Could you please try this?

                                                                                     

                                                                                    <!--- Logout --->

                                                                                    <cfif structKeyExists(variables, "sessionKey") and len(trim(variables.sessionKey))>

                                                                                      <cfhttp url="#apiURLBase#/Logout?SessionKey=#urlEncodedFormat(sessionKey)#"/>

                                                                                      <cfif CFHTTP.statuscode is "200 OK">

                                                                                        <p>Logout successful</p>

                                                                                      </cfif>

                                                                                      <cfelse>

                                                                                      <p>Logout unsuccessful</p>

                                                                                    </cfif>

                                                                                     

                                                                                    I'll follow-up regarding your second question.

                                                                                     

                                                                                    Thanks,

                                                                                    -Aaron

                                                                                    • 39. Re: Passing CF variables in soap request
                                                                                      BKBK CommunityMVP

                                                                                      Emily LaMunyon wrote:

                                                                                       

                                                                                      Second, I am interested in the ability to have the file_id be dynamic, where the user is able to select the file through a query, instead of having to hard-code it in. Is this pocssible in this scenario?


                                                                                      That immediately suggests replacing the block:

                                                                                      <!--- Get PDF File --->

                                                                                      <cfif structKeyExists(variables, "userID") and len(trim(variables.userID))>

                                                                                        <cfset cabinetName = "Surveys" />

                                                                                        <cfset fileID = "105684" />

                                                                                        <cfset tifOnly = false />

                                                                                      ...

                                                                                      ...

                                                                                       

                                                                                      with something like

                                                                                       

                                                                                      <cfquery name="getID">

                                                                                      SELECT id

                                                                                      FROM appropriate_file_TBL

                                                                                      WHERE etc., etc.

                                                                                      </cfquery>

                                                                                       

                                                                                      <!--- Get PDF File --->

                                                                                      <!--- User validation assumes cflogin/cfloginuser was used --->

                                                                                      <cfif structKeyExists(variables, "userID") and len(trim(variables.userID)) GT 0 and len(trim(getAuthUser())) GT 0>

                                                                                        <cfset cabinetName = "Surveys">

                                                                                        <cfset fileID = getID.id>

                                                                                        <cfset tifOnly = false>

                                                                                      ...

                                                                                      ...

                                                                                      1 2 Previous Next