Using a loop on a webservice within a cfc

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Using a loop on a webservice within a cfc

    Hi

    I have a webservice, running within a cfc, this webservice checks to see if a
    stock code is a valid listed company and returns the company name and other
    information. This service is working fine and can only accept one stock code
    at a time (code attached). I have quite a lot of other services that I use
    that accept a comma delimited list of stock codes and return quotes, market
    depth and other pricing information, what I would like to do is parse a comma
    delimited list into the first webservice, count the listlen then loop this
    webservice with each individual stock code: eg TLS, XXX, WES. So when the
    webservice sees XXX as not being a valid stock code a record count of 0 is
    parsed back meaning not a listed company, so after looping I would like TLS,
    WES passed back as a string value and a message generated for te screen letting
    the user know that XXX is not valid but TLS, WES are displayed or passed into
    the pricing information webservice. I have been wracking my brain for a few
    days with this one so hope this is possible and wanted to bounce it around the
    forum. Hope some one can help me please.

    Thanks
    Mark Wheeler
    :confused;


    <!--- SECURITY SEARCH FUNCTION BEGIN --->
    <cffunction name="getsecuritySearch" access="public" returntype="struct"
    displayname="get Security Search">
    <cfargument name="sessionKey" type="string" required="yes" />
    <cfargument name="securitiesList" type="string" required="no" default="">
    <cfargument name="codeSearchType" type="string" required="no" default="1">
    <cfargument name="descriptionSearchType" type="string" required="no"
    default="-1">
    <cfargument name="options" type="string" required="no" default="0">

    <cfset var local = structNew() />

    <cfset local.strReturn = structNew() />
    <cfset local.strReturn.OK = True />
    <cfset local.strReturn.Results = '' />
    <cfset local.strReturn.Error = structNew() />

    <cfset sSecuritySearchReturn = structNew()>
    <cfset sSecuritySearchReturn.error = 0>
    <cftry>
    <cfinvoke webservice="http://SecuritySearchXMLReq.wsdl"
    method="getByTextExchangeAndType" returnvariable="local.retTextExchangeAndType">
    <cfinvokeargument name="sessionKey" value="#ARGUMENTS.sessionKey#"/>
    <cfinvokeargument name="text" value="#ARGUMENTS.securitiesList#"/>
    <cfinvokeargument name="exchangeList" value="ASX"/>
    <cfinvokeargument name="securityTypeGroupList" value=""/>
    <cfinvokeargument name="codeSearchType"
    value="#ARGUMENTS.codeSearchType#"/>
    <cfinvokeargument name="descriptionSearchType"
    value="#ARGUMENTS.descriptionSearchType#"/>
    <cfinvokeargument name="activeSecurities" value="1"/>
    <cfinvokeargument name="rowStart" value="0"/>
    <cfinvokeargument name="rowCount" value="0"/>
    <cfinvokeargument name="options" value="#ARGUMENTS.options#"/>
    </cfinvoke>
    <cfset local.strReturn.Results = xmlParse(local.retTextExchangeAndType)>
    <cfcatch type="Any">
    <cfset local.strReturn.OK = False />
    <cfset local.strReturn.Error = duplicate(CFCATCH) />
    </cfcatch>
    </cftry>
    <cfreturn local.strReturn>
    </cffunction>

    <cffunction name="getSecuritySearchQuery" access="public"
    returntype="struct" displayname="get Security Details By Stock code or company
    Name" hint="return as query">
    <cfargument name="sessionKey" type="string" required="yes" />
    <cfargument name="securitiesList" type="string" required="no" default="">
    <cfargument name="codeSearchType" type="string" required="no" default="1">
    <cfargument name="descriptionSearchType" type="string" required="no"
    default="-1">
    <cfargument name="options" type="string" required="no" default="0">

    <cfset var local = structNew() />

    <cfset local.strReturn = structNew() />
    <cfset local.strReturn.OK = True />
    <cfset local.strReturn.Results = '' />
    <cfset local.strReturn.Error = structNew() />

    <cfset local.strReturn.Results = queryNew("Text, asOfDate, asOfTime, Code,
    Description, Exchange, SecType")>
    <cfset local.strResult = getsecuritySearch(sessionKey=ARGUMENTS.sessionKey,
    securitiesList=ARGUMENTS.securitiesList,
    codeSearchType=ARGUMENTS.codeSearchType,
    descriptionSearchType=ARGUMENTS.descriptionSearchT ype,
    options=ARGUMENTS.options) />
    <cfif local.strResult.OK>
    <cfset local.aGetSecuritySearch =
    XmlSearch(local.strResult.results,
    '/FEEDXMLData-SecuritySearchXMLReq/GetByTextExchangeAndType')>
    <cfset local.aGetSecuritySearchDetail =
    XmlSearch(local.strResult.results,
    '/FEEDXMLData-SecuritySearchXMLReq/GetByTextExchangeAndType/Securities/Security'
    )>
    <cfset local.GetSecuritySearchCount =
    arrayLen(local.aGetSecuritySearchDetail)>
    <cfloop index="local.i" from="1" to="#local.GetSecuritySearchCount#">
    <!--- need to handle wrong securities --->
    <cfset QueryAddRow(local.strReturn.Results)>
    <!--- AJM: only has one instance --->
    <cfset QuerySetCell(local.strReturn.Results,"Text",
    local.aGetSecuritySearch[1].XmlAttributes.Text)>
    <cfset QuerySetCell(local.strReturn.Results,"asOfDate",
    dateFormat(left(local.aGetSecuritySearch[1].XmlAttributes.asOf,10),'dd mmm
    yyyy'))>
    <cfset QuerySetCell(local.strReturn.Results,"asOfTime",
    right(local.aGetSecuritySearch[1].XmlAttributes.asOf, 8))>
    <cfset QuerySetCell(local.strReturn.Results,"Code",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Code)>
    <cfset QuerySetCell(local.strReturn.Results,"Description" ,
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Description)>
    <cfset QuerySetCell(local.strReturn.Results,"Exchange",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Exchange)>
    <cfset QuerySetCell(local.strReturn.Results,"SecType",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.SecType)>
    </cfloop>
    <cfelse>
    <cfset local.strReturn.OK = False />
    <cfset local.strReturn.Error = duplicate(local.strResult.Error) />
    </cfif>
    <cfreturn local.strReturn>
    </cffunction>
    <!--- SECURITY SEARCH FUNCTION END --->

    patord Guest

  2. Similar Questions and Discussions

    1. Can a film loop play once, then loop on the last frame(s)?
      I need a film loop to play once, then loop playback on the last frame so I can keep the LOOP of the film loop set. This will allow the tell commands...
    2. Film loop rollovers working with tell sprite, but only if Loop is checked
      on mouseWithin me cursor 280 tell sprite 40 --the sprite containing the film loop sprite(60).member = member("networkmapsbuttonroll") --swapping...
    3. newbie stuck in a loop de loop
      Hi all, thanks in advance for any help... what I want to do is: 1) read in a file containing daily total hits to certain urls within a...
    4. Urgent: Repeat loop and Film loop clash!
      Hi All, Scenario I have a script running in which the spelling which was typed in by the student is corrected. The alphabets are moved to...
    5. Help with loop inside loop and mysql queries
      Hi List. I cannot see my error: I have relation tables setup. main id entity_name main_type etc etc date_in 1 test type1 x y 2003-06-02...
  3. #2

    Default Re: Using a loop on a webservice within a cfc

    "what I would like to do is parse a comma delimited list into the first
    webservice, count the listlen then loop this webservice with each individual
    stock code:"

    So, are you trying to loop the list and make multiple webservice calls or
    trying to pass the list to the webservice and have it loop through? Sounds
    like the former. In any case, just wrap the code like this.

    <cfloop list="#myList#" index="listItem" delimeters=",">
    ..code to execute w/each iteration goes here.
    </cfloop>



    BSterner Guest

  4. #3

    Default Re: Using a loop on a webservice within a cfc

    Your right, would I need to just loop through the invocation, this is where I
    have been getting into trouble, how to parse the correct list of stocks and the
    error to display notifying the user that there was an invalid stock used in
    that list

    Cheers
    MW

    patord Guest

  5. #4

    Default Re: Using a loop on a webservice within a cfc

    Sorry, actually you don't need to <cfinvoke> it w/each loop iteration. Just
    use the createObject function and then perform the webservice function call on
    the object at each iteration of your loop.

    <cfset var objMyWs = createObject("webservice",
    "http://SecuritySearchXMLReq.wsdl");

    <cfloop ....>
    <local.retTextExchangeAndType =
    objMyWs.getByTextExchangeAndType(//arguments go here)>

    </cfloop>

    On each call you're going to get a valid or invalid response, correct? Just
    store the company code and a flag of 1 or 0 indicating whether it was good or
    not.

    So, for example, you could use an array of structs to store your results.
    Each member of the array is a struct w/2 members. The members are 1) The stock
    code; 2) The valid flag.

    You now have a data structure you can loop through to display messages, return
    to the user, or do whatever you want with.


    BSterner Guest

  6. #5

    Default Re: Using a loop on a webservice within a cfc

    Hi
    Thanks for that, here is the code I have applied that loop to but still cannot
    get the application working, please have a look. :o
    Error generated:
    Expression Exception - in
    C:\Inetpub\farcry\wholesale\includedObj\_checkStoc k.cfm : line 27
    You have attempted to dereference a scalar variable of type class
    java.lang.String as a structure with members.



    <cftry>
    <cfset count = #ListLen(FORM.Securities)#>
    <cfloop from="1" to="#count#" index="x">
    <cfscript>
    oCheckSecurity = createObject("component", "services.iress.iress");
    strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#FORM.Securities[x]#", codeSearchType=2);
    </cfscript>
    </cfloop>
    <cfdump var="#strReturn#">
    <cfif strReturn.OK>
    <cfset qCheckSecurity = strReturn.results>
    <cfelse>
    <cfthrow type="APPLICATION" detail="#strReturn.detail#"
    message="#strReturn.message#">
    </cfif>
    <cfcatch type="Any">
    <cfrethrow>
    </cfcatch>
    </cftry>

    patord Guest

  7. #6

    Default Re: Using a loop on a webservice within a cfc

    The error you're seeing is most likely because your "strReturn" variable (which
    is the web service response) is not a struct. Is it supposed to be?

    Also, do you want to halt execution and display an error if one of the codes
    is invalid, or do you want to simply "make a note of it" and continue until
    you're finished w/the list?

    As mentioned in my last post you don't need to instantiate the webservice
    w/each loop iteration. Pull the...

    oCheckSecurity = createObject("component", "services.iress.iress");

    out of the loop. You can create it once and then just keep calling it's
    function.




    BSterner Guest

  8. #7

    Default Re: Using a loop on a webservice within a cfc

    Hi

    Thanks, yeah I just want to make a note of it store as a variable to display
    on the screen, to let the user know this list element was not valid, then pull
    the other valid list elements together for process.

    MW

    patord Guest

  9. #8

    Default Re: Using a loop on a webservice within a cfc

    Ok, so using the following code.

    <cftry>
    <cfset count = ListLen(FORM.Securities)>
    <cfset oCheckSecurity = createObject("component", "services.iress.iress")>
    <cfset stockResults = StructNew()>
    <cfloop from="1" to="#count#" index="x">
    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#FORM.Securities[x]#", codeSearchType=2)>
    <cfdump var="#strReturn#">
    <cfset stockResults.FORM.Securities[x] = strReturn.OK>
    </cfloop>
    <cfcatch type="Any">
    <cfrethrow>
    </cfcatch>
    </cftry>

    You now have a Struct named 'stockResults' you can return to the calling page.
    In this calling page, you loop the struct and display the results.

    <cfloop collection="#stockResults#" item="key">
    <cfoutput>The result of this stock code query for #key# was:
    #stockResults[key]#</cfoutput>
    </cfloop>

    Not sure why you're using try/catch/throw/rethrow to handle invalid stock
    queries. You just want to record that it was invalid, not "break" your
    application.

    BSterner Guest

  10. #9

    Default Re: Using a loop on a webservice within a cfc

    Thanks for all the help, getting this struct error even though canged the
    webservice to returntype any

    12:21:46.046 - Expression Exception - in
    C:\Inetpub\farcry\wholesale\includedObj\_checkStoc k.cfm : line 30
    You have attempted to dereference a scalar variable of type class
    java.lang.String as a structure with members.


    <cftry>
    <cfset count = ListLen(FORM.Securities)>
    <cfset oCheckSecurity = createObject("component", "services.iress.iress")>
    <cfset stockResults = StructNew()>
    <cfloop from="1" to="#count#" index="x">
    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#FORM.Securities[x]#", codeSearchType=2)>
    <cfdump var="#strReturn#">
    <cfset key = FORM.Securities[x]>
    <cfset stockResults[key] = strReturn.OK>
    </cfloop>
    <cfcatch type="Any">
    <cfrethrow>
    </cfcatch>
    </cftry>

    cheers
    MW

    patord Guest

  11. #10

    Default Re: Using a loop on a webservice within a cfc

    Looking back over your code, this looks wrong.

    FORM.Securities[x]

    Your "FORM" variable is a struct, but its members are not. i.e. not unless
    convert them to be so. Post the code you're using on the submission page.


    BSterner Guest

  12. #11

    Default Re: Using a loop on a webservice within a cfc

    thanks, code attached

    MW


    <cfoutput>
    <cfif IsDefined('URL.Securities')>
    <cfset FORM.Securities = '#URL.Securities#'>
    </cfif>
    <p>
    <form action="" method="post" name="search_frm" id="search_frm">
    <table>
    <tr align="center">
    <td>comma seperated list of Securities:</td>
    <td><input type="text" name="Securities" class="formFields"></td>
    <td><input type="image"
    src="#application.url.webroot#/wsimages/btn-go.gif" alt="go" border="0"></td>
    </tr>
    </table>
    </form>
    </p>
    <cfif isDefined("FORM.Securities") AND len(trim("FORM.Securities"))>
    <cftry>
    <cfset count = ListLen(FORM.Securities)>
    <cfset oCheckSecurity = createObject("component",
    "services.iress.iress")>
    <cfset stockResults = StructNew()>
    <cfloop from="1" to="#count#" index="x">
    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#FORM.Securities#[x]", codeSearchType=2)>
    <cfdump var="#strReturn#">
    <cfset stockResults[FORM.Securities[x]] = strReturn.OK>
    </cfloop>
    <cfcatch type="Any">
    <cfrethrow>
    </cfcatch>
    </cftry>
    <cfloop collection="#stockResults#" item="key">
    <cfoutput>The result of this stock code query for #key# was:
    #stockResults[key]#</cfoutput>
    </cfloop>
    </cfif>
    </cfoutput>

    patord Guest

  13. #12

    Default Re: Using a loop on a webservice within a cfc

    This is your cfloop tag

    <cfloop list="#FORM.Securities#" index="x">

    and your webservice call

    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#x#", codeSearchType=2)>


    BSterner Guest

  14. #13

    Default Re: Using a loop on a webservice within a cfc

    is only valuating the first element of the list. ? 3 items in the list and
    dumped on the screen brings back the following.

    struct
    ERROR struct [empty]

    OK True
    RESULTS query
    ASOFDATE ASOFTIME CODE DESCRIPTION EXCHANGE SECTYPE TEXT
    1 25 Jul 2005 15:42:54 AMP AMP LIMITED ASX 100 amp brings back 1st
    item ok

    struct
    ERROR struct [empty]

    OK True
    RESULTS query
    ASOFDATE ASOFTIME CODE DESCRIPTION EXCHANGE SECTYPE TEXT
    should be 2nd item
    struct
    ERROR struct [empty]

    OK True
    RESULTS query
    ASOFDATE ASOFTIME CODE DESCRIPTION EXCHANGE SECTYPE TEXT
    should be 3rd item

    thanks
    MW

    patord Guest

  15. #14

    Default Re: Using a loop on a webservice within a cfc

    The "<cfset stockResults[FORM.Securities[x]] = strReturn.OK>" line is going to
    throw an error. "Securities" is not a struct, but a string. Sorry, think I
    gave you that and then changed it.

    Change your loop logic to this.

    <cfloop list="#FORM.Securities#" index="x">
    <cfset strReturn = oCheckSecurity.getSecuritySearchQuery(stock_code=" #x#")>
    <cfdump var="#strReturn#">
    <cfset stockResults[x] = iif(strReturn.RecordCount, true, false)>
    </cfloop>

    Also, try running this without the try/catch (or output the cfcatch.message
    var) so you can see everything that's going on.





    BSterner Guest

  16. #15

    Default Re: Using a loop on a webservice within a cfc

    Hi

    This is really starting to tick me off and I appreciate your time helping me,
    but am still just gettin one result back from a list of 3.
    Current Code:

    Cheers
    MW

    <cfif isDefined("FORM.Securities") AND len(trim("FORM.Securities"))>
    <cfset count = ListLen(FORM.Securities)>
    <cfset oCheckSecurity = createObject("component", "services.iress.iress")>
    <cfset stockResults = StructNew()>
    <cfloop list="#FORM.Securities#" index="x">
    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#x#", codeSearchType=2)>
    <cfset stockResults[x] = strReturn.results>
    <cfdump var="#stockResults[x]#">
    </cfloop>
    </cfif>

    patord Guest

  17. #16

    Default Re: Using a loop on a webservice within a cfc

    I've attached code for 2 files. Can you get these to work? In the
    'ws_caller.cfm' file change the '8500' port if you're CF server is configured
    to run on a different one. Create both files in your cf_install_dir_root.


    ==== SAVE AS 'ws_caller.cfm' ====
    <cftry>
    <cfset FORM.Securities = "TLS, XXX, WES">
    <cfset oCheckSecurity = createObject("webservice",
    "http://localhost:8500/web_service.cfc?wsdl")>
    <cfset stockResults = StructNew()>
    <cfloop list="#FORM.Securities#" index="x">
    <cfset strReturn = oCheckSecurity.getSecuritySearchQuery(stock_code=" #x#")>
    <cfdump var="#strReturn#">
    <!--- Change this variable to whatever in your webservice response
    indicates whether it was a valid stock code or not
    eg) <cfset stockResults[x] = strReturn.OK> --->
    <cfset stockResults[x] = iif(strReturn.RecordCount, true, false)>
    </cfloop>
    <cfcatch type="Any">
    <cfoutput><strong>Error: #cfcatch.Message#</strong><br /></cfoutput>
    <cfrethrow>
    </cfcatch>
    </cftry>
    <cfloop collection="#stockResults#" item="stock_code">
    <cfset msg = "Valid">
    <cfif not stockResults[stock_code]>
    <cfset msg = "Invalid">
    </cfif>
    <cfoutput>The result of the query for stock code '#stock_code#' was:
    <strong>#msg#</strong><br />
    </cfoutput>
    </cfloop>


    ==== SAVE AS 'web_service.cfc' ====
    <!--- web_service.cfc --->
    <cfcomponent>
    <cffunction name="getSecuritySearchQuery" returntype="query" access="remote"
    output="true">
    <cfargument name="stock_code" type="string" required="yes">
    <cfscript>
    var qTest = QueryNew("col1, col2");
    if (Trim(ARGUMENTS.stock_code) neq "XXX")
    {
    QueryAddRow(qTest, 1);
    QuerySetCell(qTest, "col1", "Jon");
    QuerySetCell(qTest, "col2", "Doe");
    }
    return qTest;
    </cfscript>
    </cffunction>
    </cfcomponent>

    BSterner Guest

  18. #17

    Default Re: Using a loop on a webservice within a cfc

    Hi

    Thanks for all your help I got it working now with a few tweaks to the code.
    The first problem I was having was that there was no record count coming back
    for the check to see if there were any records, so I modified the webservice to
    count the XML nodes for that result and using, also had not trimmed the
    securities list so the spaces in the comma separated list were being passed
    also as part of the argument, silly mistake, any way thanks again.


    <!--- Page call --->
    <cftry>
    <cfset oCheckSecurity = createObject("component",
    "services.iress.iress")>
    <cfset stockResults = StructNew()>
    <cfloop list="#FORM.Securities#" index="x">
    <cfset strReturn =
    oCheckSecurity.getSecuritySearchQuery(sessionkey=S ESSION.iress.key,
    securitiesList="#x#", codeSearchType=2)>
    <cfset stockResults[x] = strReturn.ok>
    <cfset stockResults[x] = iif(strReturn.count, 1, 0)>
    </cfloop>
    <cfcatch type="Any">
    <cfoutput><strong>Error: #cfcatch.Message#</strong><br/>
    </cfoutput>
    <cfrethrow>
    </cfcatch>
    </cftry>
    <cfset securitiesList = "">
    <cfloop collection="#stockResults#" item="stock_code">
    <cfset msg = "Valid">
    <cfif not stockResults[stock_code]>
    <cfset msg = "Invalid">
    </cfif>
    <cfif #msg# is 'Valid'>
    <!--- This value to be passed into any other sevice as a csv list --->
    <cfset securitiesList = ListAppend(securitiesList,
    '#trim(stock_code)#', ',')>
    <cfelse>
    <!--- Display the stocks that were invalid --->
    The result of the query for stock code '#trim(stock_code)#' was:
    <strong>#msg#</strong><br />
    </cfif>
    </cfloop>
    <cftry>

    <!--- getSecuritySearchQuery Webservice --->
    <cffunction name="getsecuritySearch" access="public" returntype="struct"
    displayname="get Security Search">
    <cfargument name="sessionKey" type="string" required="yes" />
    <cfargument name="securitiesList" type="string" required="no" default="">
    <cfargument name="codeSearchType" type="string" required="no" default="1">
    <cfargument name="descriptionSearchType" type="string" required="no"
    default="-1">
    <cfargument name="options" type="string" required="no" default="0">

    <cfset var local = structNew() />

    <cfset local.strReturn = structNew() />
    <cfset local.strReturn.OK = True />
    <cfset local.strReturn.Results = '' />
    <cfset local.strReturn.Error = structNew() />

    <cfset sSecuritySearchReturn = structNew()>
    <cfset sSecuritySearchReturn.error = 0>
    <cftry>
    <cfinvoke
    webservice="http://webservices.com.au/wsdl/SecuritySearchXMLReq.wsdl"
    method="getByTextExchangeAndType" returnvariable="local.retTextExchangeAndType">
    <cfinvokeargument name="sessionKey" value="#ARGUMENTS.sessionKey#"/>
    <cfinvokeargument name="text"
    value="#trim(ARGUMENTS.securitiesList)#"/>
    <cfinvokeargument name="exchangeList" value="ASX"/>
    <cfinvokeargument name="securityTypeGroupList" value=""/>
    <cfinvokeargument name="codeSearchType"
    value="#ARGUMENTS.codeSearchType#"/>
    <cfinvokeargument name="descriptionSearchType"
    value="#ARGUMENTS.descriptionSearchType#"/>
    <cfinvokeargument name="activeSecurities" value="1"/>
    <cfinvokeargument name="rowStart" value="0"/>
    <cfinvokeargument name="rowCount" value="0"/>
    <cfinvokeargument name="options" value="#ARGUMENTS.options#"/>
    </cfinvoke>
    <cfset local.strReturn.Results = xmlParse(local.retTextExchangeAndType)>
    <cfcatch type="Any">
    <cfset local.strReturn.OK = False />
    <cfset local.strReturn.Error = duplicate(CFCATCH) />
    </cfcatch>
    </cftry>
    <cfreturn local.strReturn>
    </cffunction>

    <cffunction name="getSecuritySearchQuery" access="public"
    returntype="struct" displayname="get Security Details By Stock code or company
    Name" hint="return as query">
    <cfargument name="sessionKey" type="string" required="yes" />
    <cfargument name="securitiesList" type="string" required="no" default="">
    <cfargument name="codeSearchType" type="string" required="no" default="1">
    <cfargument name="descriptionSearchType" type="string" required="no"
    default="-1">
    <cfargument name="options" type="string" required="no" default="0">

    <cfset var local = structNew() />

    <cfset local.strReturn = structNew() />
    <cfset local.strReturn.OK = True />
    <cfset local.strReturn.Results = '' />
    <cfset local.strReturn.Error = structNew() />

    <cfset local.strReturn.Results = queryNew("Text, asOfDate, asOfTime, Code,
    Description, Exchange, SecType")>
    <cfset local.strResult = getsecuritySearch(sessionKey=ARGUMENTS.sessionKey,
    securitiesList=ARGUMENTS.securitiesList,
    codeSearchType=ARGUMENTS.codeSearchType,
    descriptionSearchType=ARGUMENTS.descriptionSearchT ype,
    options=ARGUMENTS.options) />
    <cfif local.strResult.OK>
    <cfset local.aGetSecuritySearch =
    XmlSearch(local.strResult.results,
    '/XMLData-SecuritySearchXMLReq/GetByTextExchangeAndType')>
    <cfset local.aGetSecuritySearchDetail =
    XmlSearch(local.strResult.results,
    '/XMLData-SecuritySearchXMLReq/GetByTextExchangeAndType/Securities/Security')>
    <cfset local.GetSecuritySearchCount =
    arrayLen(local.aGetSecuritySearchDetail)>
    <cfloop index="local.i" from="1" to="#local.GetSecuritySearchCount#">

    <cfset QueryAddRow(local.strReturn.Results)>

    <cfset QuerySetCell(local.strReturn.Results,"Text",
    local.aGetSecuritySearch[1].XmlAttributes.Text)>
    <cfset QuerySetCell(local.strReturn.Results,"asOfDate",
    dateFormat(left(local.aGetSecuritySearch[1].XmlAttributes.asOf,10),'dd mmm
    yyyy'))>
    <cfset QuerySetCell(local.strReturn.Results,"asOfTime",
    right(local.aGetSecuritySearch[1].XmlAttributes.asOf, 8))>
    <cfset QuerySetCell(local.strReturn.Results,"Code",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Code)>
    <cfset QuerySetCell(local.strReturn.Results,"Description" ,
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Description)>
    <cfset QuerySetCell(local.strReturn.Results,"Exchange",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.Exchange)>
    <cfset QuerySetCell(local.strReturn.Results,"SecType",
    local.aGetSecuritySearchDetail[local.i].XmlAttributes.SecType)>
    </cfloop>
    <cfset local.strReturn.count = #local.GetSecuritySearchCount# />
    <cfelse>
    <cfset local.strReturn.OK = False />
    <cfset local.strReturn.Error = duplicate(local.strResult.Error) />
    <cfset local.strReturn.count = #local.GetSecuritySearchCount# />
    </cfif>
    <cfreturn local.strReturn>
    </cffunction>

    patord Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139