How to pass array of sting to non-CF web service?

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

  1. #1

    Default How to pass array of sting to non-CF web service?

    My co-worker develops a Java web service which takes an array of user IDs and
    return the email addresses for those IDs.

    However, I just can't pass the array of User IDs to his web service. Other
    java developers can use his web service without any problem.

    Here is part of WSDL:
    - <types>
    - <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:ope="http://www.openuri.org/" elementFormDefault="qualified"
    targetNamespace="http://www.openuri.org/">
    - <s:element name="getStaffByUsername">
    - <s:complexType>
    - <s:sequence>
    <s:element name="userName" type="ope:ArrayOfString" minOccurs="0" />
    </s:sequence>
    </s:complexType>
    </s:element>
    - <s:element name="getStaffByUsernameResponse">
    - <s:complexType>
    - <s:sequence>
    <s:element name="getStaffByUsernameResult" type="ope:ArrayOfStaffUser"
    minOccurs="0" />
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="ArrayOfStaffUser" nillable="true"
    type="ope:ArrayOfStaffUser" />
    - <s:complexType name="ArrayOfString">
    - <s:sequence>
    <s:element name="String" type="s:string" nillable="true" minOccurs="0"
    maxOccurs="unbounded" />
    </s:sequence>
    </s:complexType>
    - <s:complexType name="ArrayOfStaffUser">
    - <s:sequence>
    <s:element name="StaffUser" type="ope:StaffUser" nillable="true"
    minOccurs="0" maxOccurs="unbounded" />
    </s:sequence>
    </s:complexType>
    - <s:complexType name="StaffUser">
    - <s:sequence>
    <s:element name="user_name" type="s:string" minOccurs="0" />
    <s:element name="person_id" type="s:string" minOccurs="0" />
    <s:element name="user_name_id" type="s:string" minOccurs="0" />
    <s:element name="term_date" type="s:string" minOccurs="0" />
    <s:element name="prime" type="s:string" minOccurs="0" />
    <s:element name="locked" type="s:string" minOccurs="0" />
    <s:element name="last_name" type="s:string" minOccurs="0" />
    <s:element name="first_name" type="s:string" minOccurs="0" />
    <s:element name="middle_name" type="s:string" minOccurs="0" />
    <s:element name="group_id" type="s:string" minOccurs="0" />
    <s:element name="division_id" type="s:string" minOccurs="0" />
    <s:element name="site" type="s:string" minOccurs="0" />
    <s:element name="email_address" type="s:string" minOccurs="0" />
    <s:element name="employee" type="s:string" minOccurs="0" />
    <s:element name="phone_number" type="s:string" minOccurs="0" />
    <s:element name="building_id" type="s:string" minOccurs="0" />
    <s:element name="room_id" type="s:string" minOccurs="0" />
    <s:element name="mail_stop" type="s:string" minOccurs="0" />
    <s:element name="publish" type="s:string" minOccurs="0" />
    <s:element name="agency" type="s:string" minOccurs="0" />
    </s:sequence>
    </s:complexType>
    </s:schema>
    </types>
    ------------------------------------

    And here is my code

    <cfscript>
    stUser = arrayNew(1);
    stUser[1]="ddao";
    stUser[2]="kkewt";
    </cfscript>
    <cfdump var="#stUser#">
    <cfinvoke
    webservice="http://wye.nist.gov:7001/AMS/AMSLookup/LookupStaffUser.jws?WSDL"
    method="getStaffByUsername"
    returnvariable="aArrayOfStaffUser">
    <cfinvokeargument name="userName" value="#stUser#"/>
    </cfinvoke>

    --------------------------------------------------------------------------------
    ----------------------------------------

    And here is the error I got:
    Could not perform web service invocation "getStaffByUsername".
    Here is the fault returned when invoking the web service operation:

    java.lang.IllegalArgumentException: argument type mismatch


    jj3001 Guest

  2. Similar Questions and Discussions

    1. How do you pass an array of structures to webservice?
      Hello, Does anyone have an example of how to pass an array of strings (ie purchase Id's) from CF to a web service (like weblogic), and then...
    2. CFC array pass a URL?
      Can you pass a hyperlink as a varaible in an array using CFC and Flash? In other words, I am trying to pass a hyperlink from a CFC to Flash using...
    3. how to pass multi array as args
      Can someone show me how to pass multiple arrays argument? ie - .... mysub(@a, @b, @c); .... sub mysub { my @a = ? #arg1 an array $_ is...
    4. Can ASP pass an Array into a Function?
      Hello, Can anyone tell me if ASP can pass an Array intp a Function? If so, can anyone point me to an example? Thanks in advance. Gram.
    5. How to pass array values to ASP part
      Any values that exist in the client have to be sent back to the server by submitting a form, refreshing a page with a querystring, or some other...
  3. #2

    Default Re: How to pass array of sting to non-CF web service?

    All u need to do is pass a structure and it is done this way:

    <cfscript>
    function SmartArray(lItems,delim)
    {
    var ArrayContainer=StructNew();
    ArrayContainer.string=ListToArray(lItems,delim);
    return ArrayContainer;
    }
    Services = SmartArray("IPLI",",");
    </cfscript>
    <cfdump var="#Services#">

    just pass #Services# as the value... u cannot pass arry like this... u can only give refernce to the arry like abc_array[2] and if your WS excepts a string arrar u need to create a structure as sepcified above... dont pass array with index, it will not except it
    Unregistered 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