Professional Web Applications Themes

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

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> ...

  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. #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

Similar Threads

  1. How do you pass an array of structures to webservice?
    By kedward in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: June 8th, 11:11 PM
  2. CFC array pass a URL?
    By redman2215 in forum Coldfusion Flash Integration
    Replies: 0
    Last Post: April 1st, 11:04 PM
  3. how to pass multi array as args
    By perl@swanmail.com in forum PERL Beginners
    Replies: 11
    Last Post: November 17th, 06:13 AM
  4. Replies: 6
    Last Post: October 16th, 02:25 PM
  5. How to pass array values to ASP part
    By Ray at in forum ASP Database
    Replies: 2
    Last Post: August 6th, 01:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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