5 Replies Latest reply on Jul 24, 2009 12:46 PM by mgw4jc

    Webservices Question

    kenji776 Level 1

      Hello all,

      I am again working with the Angel.com  IVR outbound API (I posted here once before about this). This time I need to get the statuses of call that have been placed. They have a function called getStatus() where you simply pass in an array of call identifies, and they give you have info about them. The problem is that I cannot figure out how to access the information, because they give back an array of functions (some of which contain other functions).

       

      They do have sample code for numerous languages. Here is the java sample, since that is closest to Cold Fusion. Here is their code that does what I want.

       

              ocss = oc.getStatus(ocl.getToken(), guids.toArray(new String[0]));
            
               /**
               * Print out status information of each call.
               */
      
            
              for(int i = 0; i < ocss.length; i++) {
                  CallIDentifier cid = ocss[i].getCallIDentifier();
      
                  for(int j = 0; j < ocss[i].getStatusItems().length; j++) {
      
                      OutboundCallStatusItem ocsi = ocss[i].getStatusItems()[j];
                      System.out.println(cid.getOutboundCallGUID() + "|\t\t\t|" + 
                                         cid.getPhoneNumber() + "|\t\t\t|" + 
                                         ocsi.getMessage() + "|\t\t\t|" + 
                                         ocsi.getStatus());
                  }
              }
      

      The line that confuses me there is

      OutboundCallStatusItem ocsi = ocss[i].getStatusItems()[j];
      


      What the hell is that [j] doing after the function call? That syntax simply does not compute for me. Either way I tried to write a similar cold fusion function

           <cffunction name="GetCallStatus" access="public" hint="Find call statuses for an array of call GUID's">
                <cfargument name="outBoundCallGUIDs" type="array" hint="An array of call GUID's" required="yes">
                <cfargument name="token" type="string" hint="Login token for the API" required="yes">
                <cfset var CallInfo = [] />     
                
                <!--- Send the call object to the webservice --->
                <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="getStatus" returnvariable="ocss">
                     <cfinvokeargument name="token" value="#arguments.Token#"/>
                     <cfinvokeargument name="outboundCallGUIDs" value="#arguments.outboundCallGUIDs#"/>
                </cfinvoke> 
                
      <cfloop from="0" to="#arraylen(ocss[i].getStatusItems())#" index="j">
      <cfset CallInfo[i]["EntireReturnedObject"] = ocss[i]>
      <cfset CallInfo[i]["CallGuid"] = cid.getOutboundCallGUID()>
      <cfset Callinfo[i]["NumberDialed"] = cid.getPhoneNumber()>
      <cfset Callinfo[i]["Object"] = cid>
      <cfset Callinfo[i]["ocsi"] = ocss[i].getStatusItems()>
      
      <!---- Does not work, returns "Invalid CFML construct found on line 248 at column 96."
      <cfset CallInfo[i]["GetStatusItems"] = ocss[i].getStatusItems()[j]>
      ---->
      
      <!--- Does not work, returns "1 null <br>The error occurred on line 244."
      <cfset CallInfo[i]["GetStatusItems"] = ocss[i].getStatusItems(j)>
      ---->
                     
      <!--- Does nto work, returns "The getMesage method was not found."
      <cfset Callinfo[i]["Message"] = ocss[i].getStatusItems().getMesage()>
      ----->
      </cfloop>
      
                
                <cfreturn CallInfo>
           </cffunction>
      

      But the last <cfset> line in the loop fails. I have no idea how to reference the getStartTime function which is stored in the getStatusItems function.

      I am totally stuck, I have tried a million variation on sytax, and I always get errors stating that the getStartTime method cannot be found, even though it does very clearly exist withing the getStatusItems().

       

      You can see my test page here, to see the data that is getting returned.

      http://portal.fpitesters.com/ivr/getCallStatus.cfm

       

      You can see their java sample code here

      http://www.socialtext.net/ivrwiki/index.cgi?java_sample_code

       

      Here is their whole library on the API, with other sample code languages listed at the bottom of the page, as well as more information on the getStatus function.

      http://www.socialtext.net/ivrwiki/index.cgi?java_sample_code

       

      Any help is appreciated. Thank you.

      (FYI when i get all this done I do plan on releasing a CFC with all these functions put together so other CF coders can use Angel.com without having to fight through all the crap I am).

        • 1. Re: Webservices Question
          mgw4jc

          getStatusItems()[j] means that the getStatusItems is returning an array and then getting the element at index j. This syntax is not supported in ColdFusion (it will be in CF9).

           

          To handle this, you would first have to assign a variable to hold the array, then use that to get the element.

          <cfset CallInfo[i]["GetStatusItems"] = ocss[i].getStatusItems()>

          <cfset CallInfo[i]["Message"] = CallInfo[i]["GetStatusItems"][j].getMessage()>

          • 2. Re: Webservices Question
            kenji776 Level 1

            Thank you so much for your reply. I cannot tell you how this problem has been bother me. I did try your code, and while it seems to be much closer, it still wasn't quite right. I used the following code

             

                      
                      <cfloop from="1" to="#arraylen(ocss)#" index="i">
                           <cfset cid = ocss[i].getCallIDentifier()>
                           
                           <cfloop from="0" to="#arraylen(ocss[i].getStatusItems())#" index="j">
                                <cfset CallInfo[i]["CallGuid"] = cid.getOutboundCallGUID()>
                                <cfset Callinfo[i]["NumberDialed"] = cid.getPhoneNumber()>
                                <cfset CallInfo[i]["GetStatusItems"] = ocss[i].getStatusItems()> 
                                <cfset CallInfo[i]["Message"] = CallInfo[i]["GetStatusItems"][j].getMessage()>
            
                           </cfloop>
            
                      </cfloop>
            
            

             

            But I get the error

             

            The element at position 0, of dimension 3, of an array object used as part of an expression, cannot be found. <br>The error occurred on line 246.

             

            246 being the

            <cfset CallInfo[i]["Message"] = CallInfo[i]["GetStatusItems"][j].getMessage()>

            Line. I am sure it is something really simple at this point, just waaay to deep in the forest to see the trees anymore. Again, thank you so much for your help, I truly appreciate it.

            • 3. Re: Webservices Question
              mgw4jc Level 1

              For the outer cfloop you have from="0". Try from="1". CF uses 1-based arrays instead of 0-based.

              • 4. Re: Webservices Question
                kenji776 Level 1

                Haha,

                I knew it was going to be something super easy. Simple things get forgotten so easily sometimes. Thank you so much. It works now.

                • 5. Re: Webservices Question
                  kenji776 Level 1

                  The fun never ends. Trying to find the start time and end time returns this horrible mess of other crap, apperantly everything required to build a gregorian calender or something. Check this out.

                   

                  http://portal.fpitesters.com/ivr/getCallStatus.cfm

                   

                  I guess I get to try and figure out how to make something that looks like a time out of that. Again any ideas are welcome, though I can certainly try to figure it out as well. Thanks.