Re: How to pass a file to a web service.

2011-03-11 Thread Mack

Use the binary type when declaring the web service parameter for the
file content, have a separate parameter for the file name (if
necessary) and use the normal CF way to invoke the web service.
Theoretically you shouldn't get Out of Memory errors but I haven't
tested this...

ws.cfc
cffunction name=dataSubmit access=remote
 cfargument name=file_name type=string
 cfargument name=file type=binary

cfset fileWrite(arguments.file_name, arguments.file)

/cffunction


test.cfm
cfset ws = createObject(webservice, http://ws.cfc?wsdl;)
cfset ws.dataSubmit(ppur-test.xml, fileRead(expandPath('ppur-test.xml')))

-- 
Mack

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342917
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


How to pass a file to a web service.

2011-03-10 Thread Ian Skinner

What would be the web service equivalent of this HTTP request?

wsTest.cfm

|cfhttp url=https://secure-devsite/pur-loader/ws/ppur_v0.cfc; method=post 
multipart=yes
  cfhttpparam name=authentication value= 
type=formfield
  cfhttpparam name=ppurfile file=#expandPath('ppur-test.xml')# 
type=file
  cfhttpparam name=method value=dataSubmit type=url
/cfhttp
cfoutput#htmlEditFormat(cfhttp.FileContent)#/cfoutput
|

ppur_v0.cfc

|cffunction name=dataSubmit access=remote output=no returntype=xml
  cfargument name=authentication type=string required=yes 
hint=authentication value
  cfargument name=ppurFile type=string required=yes hint=file 
upload field

 cfset var dataResult = 
  cfset var rootpath = getDirectoryFromPath(getCurrentTemplatePath())

  cfset path = 
replace(rootpath,htdocs/pur-loader/ws/,uploadedFiles/ppur/,ONE)

  cffile action=upload filefield=ppurFile destination=#path# 
nameconflict=overwrite

  cfset var validate = xmlValidate(cffile.serverDirectory  '/'  
cffile.serverFile,replace(rootpath,'/ws/','/schema/ppur-data-transmission.xsd','ONE'))
...
/cffunction
|

I.E.  How would one pass a 'file' to a web service?  Or can you only 
pass the content of the file as a string?  Which is differernt and 
apparently does not work for what we are trying to do.  When I did that, 
we would start getting 'java heap out of memory' errors dealing with the 
quanty of content we need to pass to this web service.

To clarify, is there a way to pass a file reference through a web 
service object that can be used in a cffile action=upload... tag in 
the cffunction... block?



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342890
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: How to pass a file to a web service.

2011-03-10 Thread Dean Lawrence

Ian, you would need to convert the uploaded file to base64 before
submitting it to the web service. This essentially will transfer the
file as text. Once the web service has it, you would then convert it
back to it's original binary format. Ben Nadel has an article
describing this process.
http://www.bennadel.com/blog/1113-Posting-File-Data-Using-A-Base64-Encoding-In-ColdFusion.htm

On Thu, Mar 10, 2011 at 10:20 AM, Ian Skinner h...@ilsweb.com wrote:

 What would be the web service equivalent of this HTTP request?

 wsTest.cfm

 |cfhttp url=https://secure-devsite/pur-loader/ws/ppur_v0.cfc; method=post 
 multipart=yes
      cfhttpparam name=authentication value= 
 type=formfield
      cfhttpparam name=ppurfile file=#expandPath('ppur-test.xml')# 
 type=file
      cfhttpparam name=method value=dataSubmit type=url
 /cfhttp
 cfoutput#htmlEditFormat(cfhttp.FileContent)#/cfoutput
 |

 ppur_v0.cfc

 |cffunction name=dataSubmit access=remote output=no returntype=xml
      cfargument name=authentication type=string required=yes 
 hint=authentication value
      cfargument name=ppurFile type=string required=yes hint=file 
 upload field

         cfset var dataResult = 
      cfset var rootpath = getDirectoryFromPath(getCurrentTemplatePath())

      cfset path = 
 replace(rootpath,htdocs/pur-loader/ws/,uploadedFiles/ppur/,ONE)

      cffile action=upload filefield=ppurFile destination=#path# 
 nameconflict=overwrite

      cfset var validate = xmlValidate(cffile.serverDirectory  '/'  
 cffile.serverFile,replace(rootpath,'/ws/','/schema/ppur-data-transmission.xsd','ONE'))
 ...
 /cffunction
 |

 I.E.  How would one pass a 'file' to a web service?  Or can you only
 pass the content of the file as a string?  Which is differernt and
 apparently does not work for what we are trying to do.  When I did that,
 we would start getting 'java heap out of memory' errors dealing with the
 quanty of content we need to pass to this web service.

 To clarify, is there a way to pass a file reference through a web
 service object that can be used in a cffile action=upload... tag in
 the cffunction... block?



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342892
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: How to pass a file to a web service.

2011-03-10 Thread Ian Skinner

On 3/10/2011 8:05 AM, Dean Lawrence wrote:
 Ian, you would need to convert the uploaded file to base64 before
 submitting it to the web service. This essentially will transfer the
 file as text.

What would be the result of converting a text file to base64?  I'm not 
dealing with a binary file format.  This file is XML data stored as 
basic text, ASCII I presume.

It is the size of the file that is causing problem.  For some reason, 
ColdFusion can handle it works with a file that has been uploaded by the 
web server to the temp folder.  But receiving the contents directly 
through a web service invocation throws Java Heap Out Of Memory errors.



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342893
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: How to pass a file to a web service.

2011-03-10 Thread Dean Lawrence

If it is a file, then yes it is binary. The contents may be ASCII
text, but the file itself is binary. When you convert the file to
base64, you are converting it into a text string. This you can pass to
the web service. The web service would then read the string, convert
it back binary and use the cffile tag to save it.

On Thu, Mar 10, 2011 at 11:20 AM, Ian Skinner h...@ilsweb.com wrote:

 On 3/10/2011 8:05 AM, Dean Lawrence wrote:
 Ian, you would need to convert the uploaded file to base64 before
 submitting it to the web service. This essentially will transfer the
 file as text.

 What would be the result of converting a text file to base64?  I'm not
 dealing with a binary file format.  This file is XML data stored as
 basic text, ASCII I presume.

 It is the size of the file that is causing problem.  For some reason,
 ColdFusion can handle it works with a file that has been uploaded by the
 web server to the temp folder.  But receiving the contents directly
 through a web service invocation throws Java Heap Out Of Memory errors.



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342895
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm