Invoking a Web Service passing 2 files not working

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

  1. #1

    Default Invoking a Web Service passing 2 files not working

    On our project we are building an ebXML registry server and exposing all the
    methods as web services.

    I am building the front end in ColdFusion. The following are three methods we
    created as web services using java. All three work with a Java client and a
    ..Net client, the third method breaks when being invoked using ColdFusion.

    1. loginUser(name,password)
    2. uploadFile(arrayofbyte_1)
    3. uploadFiles(arrayofbyte_1, arrayofbyte_2)

    The reason I mention all three of these methods is that it is not an issue of
    having 2 arguments or passing in files (which are converted to binary in order
    to map to the arrayofbyte javatype). I can successfully pass 2 arguments (1),
    I can successfully pass 1 file (2), but it breaks every time when I pass 2
    files .

    Here is the error:
    Web service operation "uploadFiles" with parameters
    {{ARRAYOFBYTE_1={60631205},ARRAYOFBYTE_2={60631202 },}} could not be found.

    I noticed that the method (as noticed in the error) is adding a comma after
    the last argument. This makes me think that the invocation is looking for a
    method with three arguments, but this is a shot in the dark. As I said, the
    web service can be successfully invoked using a java client and a .Net client.

    Here are the three ways I have tried invoking the method (both ways break with
    the same error). Each way has this preamble:

    <cffile
    action="upload"
    destination="c:\temp\temp\"
    nameConflict="makeunique"
    fileField="Form.filetoupload1" />
    <cffile
    action="readbinary"
    charset="utf-8"
    file="c:\temp\temp\#cffile.serverFile#"
    attributes="system"
    variable="file1" />

    <cffile
    action="upload"
    destination="c:\temp\temp\"
    nameConflict="makeunique"
    fileField="Form.filetoupload2" />
    <cffile
    action="readbinary"
    charset="utf-8"
    file="c:\temp\temp\#cffile.serverFile#"
    attributes="system"
    variable="file2" />

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

    ONE:[\b]
    <cfset args = StructNew() />
    <cfset args.arrayOfByte_2 = "#file1#" />
    <cfset args.arrayOfByte_1 = "#file2#" />
    <cfscript>
    ws = createObject('webservice', 'http://url?WSDL');
    ws.uploadFiles(args);
    </cfscript>

    TWO:
    <cfset args = StructNew() />
    <cfset args.arrayOfByte_2 = "#file1#" />
    <cfset args.arrayOfByte_1 = "#file2#" />
    <cfinvoke
    webservice="http://url?WSDL"
    method="uploadFiles"
    argumentcollection="#args#" />

    THREE:
    <cfinvoke
    webservice="http://url?WSDL"
    method="uploadFiles" />
    <cfinvokeargument name="arrayOfbyte_1" value="#file1#">
    <cfinvokeargument name="arrayOfbyte_2" value="#file2#">
    </cfinvoke>

    Any help on this would be greatly appreciated.

    McKormick Guest

  2. Similar Questions and Discussions

    1. Error Invoking Web Service
      Hopefully someone has seen this and has an answer. I am trying to invoke a web service which takes a string of XML as a parameter. I have attached...
    2. Duplicate file name when invoking a web service
      Actually the filename and display name can match, but they have to match in *case* too. this is for two reasons: 1. An enhancement to web...
    3. Exception when invoking web service from asp .net form
      When creating the instance to invoke a web service method, I always get the exception shown at the bottom. The .dll file changes randomly, although...
    4. passing parameters to or invoking a method of an activex control in asp
      I wrote a simple client/server chat program and the client runs as an activex control within an asp page. I have the users logging into the page...
    5. 404 error invoking web service
      Hi, I'm having a problem with a web service that I wrote. I first wrote & tested the web service on my local (XP) machine. I used visual studio to...
  3. #2

    Default Re: Invoking a Web Service passing 2 files not working

    Following up,

    The Java Class is requesting the data type be an Array of Bytes, while
    coldfusion is passing binary objects. I'm confident that this is correct as I
    can successfully pass the file when the Web Service has only one argument. I
    just want to confirm that this is the recommended method (datatypes, etc).

    McKormick Guest

  4. #3

    Default Re: Invoking a Web Service passing 2 files not working

    - In your 'ONE' example, just pass it as 2 arguments rather than an argument
    collection.
    - In your 'THREE' example, it looks like your terminating the 'cfcomponent'
    tag before finishing. Try the following.

    I tested both (CFMX 6.1 & Tomcat 4.1.29) and it worked fine for me. Also,
    make sure you test the 'http://url?WSDL' url in a browser to make sure you're
    being returned the correct wsdl data. If using the 'cfinvoke' tag, you can set
    a name for the Web Service in the Coldfusion administrator (Assuming you have
    access to this). Good way to make sure nothing's broken before trying to use
    it.



    Eg)

    <cffile action="readbinary"
    file="#GetDirectoryFromPath(ExpandPath("*.*"))#\ex ec1.exe"
    variable="arrayOfByte_1">
    <cffile action="readbinary"
    file="#GetDirectoryFromPath(ExpandPath("*.*"))#\ex ec2.exe"
    variable="arrayOfByte_2">

    'ONE'
    <cfscript>
    ws = createObject("webservice", "http://url?WSDL");
    ws.uploadFile(arrayOfByte_1, arrayOfByte_2);
    </cfscript>

    'THREE'
    <cfinvoke webservice="http://url?WSDL" method="uploadFiles">
    <cfinvokeargument name="arrayOfbyte_1" value="#file1#">
    <cfinvokeargument name="arrayOfbyte_2" value="#file2#">
    </cfinvoke>

    BSterner Guest

  5. #4

    Default Re: Invoking a Web Service passing 2 files not working

    Thanks,

    I pasted incorrectly, I wasn't actually closing my cfinvoke tag prematurely.

    However, for some reason, the first option you mentioned worked even though
    the cfinvoke tag doesn't. That is excellent, even though I don't understand
    why.

    However, it seems that by using the cfinvoke tag, ColdFusion was rearranging
    the variables and adding an extra comma at the end of the invoker which was
    causing the Web Service to think it was looking for a 3 argument method rather
    than a 2 argument method.

    Could whitespace have anything to do with this?

    McKormick Guest

  6. #5

    Default Re: Invoking a Web Service passing 2 files not working

    Whitespace in your cfm file? Don't think that should matter. I noticed the
    order of your file arguments was different.

    You had.

    <cfset args.arrayOfByte_2 = "#file1#" />
    <cfset args.arrayOfByte_1 = "#file2#" />

    Which seemed backwards to me. Are the arguments (and values) being passed in
    the exact same order in both cases? The order should match your java method.

    Also, you can specify argument names in your ws method call. Like...

    'ONE'
    <cfscript>
    ws = createObject("webservice", "http://url?WSDL");
    ws.uploadFiles(arrayOfByte_1=file1, arrayOfByte_2=file2);
    </cfscript>

    Yet another way to do it....

    <cfobject webservice= "http://url?WSDL" />
    <cfset objWS.uploadFiles(file1, file2)>
    <cfset objWS.uploadFiles(arrayOfByte_1=file1, arrayOfByte_2=file2)>


    BSterner 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