Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
McKormick #1
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
-
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... -
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... -
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... -
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... -
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... -
McKormick #2
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
-
BSterner #3
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
-
McKormick #4
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
-
BSterner #5
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



Reply With Quote

