logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Stumped: nusoap client sending binary data to server: msg#00058

Subject: Re: Stumped: nusoap client sending binary data to server
If you want to use SOAP in this case, you have three important pieces of code.

1. The HTML page that will allow the user to specify a file name and upload 
that file, i.e. it will have a form with an enctype of multipart/form-data and 
an input with a type of file.

2. The PHP/NuSOAP script that will be the action for the HTML form in #1.  This 
script will get the contents of the file within the HTTP POST, then pass the 
contents as a parameter in the soapclient->call('UploadFile', ...);

3. The PHP/NuSOAP script that will be the SOAP service, i.e. the script with 
the UploadFile method, etc., you show below.

My earlier e-mail made the point that once you have #1 from this list, all you 
need is a PHP script to be the action for the HTML form that will save the file 
wherever you want, as is done in the UploadFile method.  Your introduction of 
SOAP into this task seems unnecessary to me.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Douglass Turner" <douglass.turner@xxxxxxxxx>
To: "Scott Nichol" <snicholnews@xxxxxxxxxxxxxxx>
Sent: Thursday, November 18, 2004 2:52 PM
Subject: Re: [Nusoap-general] Stumped: nusoap client sending binary data to 
server


> Just to be crystal clear hear, are you saying to simply use the soap
> service as the "action" in a form? As I would with a typical CGI
> script?
> 
> -Douglass
> 
> 
> On Wed, 17 Nov 2004 08:54:47 -0500, Scott Nichol
> <snicholnews@xxxxxxxxxxxxxxx> wrote:
> > I have a recommendation for your server: use base64Binary, which will 
> > encode the data more compactly than an array of unsignedByte.  The code 
> > looks like
> > 
> >  $server->register('UploadFile', // method name
> >                   // input parameters
> >                   array('bytes' => 'xsd:base64Binary', 'filename' => 
> > 'xsd:string'),
> > 
> > 
> >                   // output parameters
> >                   array('return' => 'xsd:boolean'),
> >                   // namespace
> >                   $ns,
> >                   // soapaction
> >                   $ns . '#UploadFile',
> >                   // style
> >                   'rpc',
> >                   // use
> >                   'encoded',
> >                   // documentation
> >                   'Upload a File'
> >  );
> > function UploadFile($bytes, $filename) {
> >     // Save file to specified directory using filename
> >     $fp = fopen("upload_directory/$filename", "w");
> >     fwrite($fp, base64_decode($bytes));
> >     fclose($fp);
> >     return true;
> > }
> > 
> > The client code to "upload" the file is PHP/NuSOAP code that uses the 
> > NuSOAP soapclient class to call the UploadFile method.  If you want the 
> > user interface to be in a browser, you would have an HTML page with a form 
> > for the user to specify the filename.  When the form is posted, it would 
> > upload the file to the HTTP server with a target of your PHP.  That page 
> > would read the posted file data then call UploadFile through SOAP.  As you 
> > probably notice, if you want a user to upload a file from a browser, you 
> > are best off using the capabilities built into HTML.  In that case, SOAP 
> > just adds extra work.
> > 
> > Scott Nichol
> > 
> > Do not send e-mail directly to this e-mail address,
> > because it is filtered to accept only mail from
> > specific mail lists.
> > 
> > 
> > ----- Original Message -----
> > From: "Douglass Turner" <douglass.turner@xxxxxxxxx>
> > To: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
> > Sent: Wednesday, November 17, 2004 8:03 AM
> > Subject: [Nusoap-general] Stumped: nusoap client sending binary data to 
> > server
> > 
> > > Hello,
> > >
> > > I've started experimenting with nusoap and intend to use it to deploy
> > > an image manipulation service I am building. I am a bit unclear on how
> > > to transmit binary data (a jpeg image for example) to the service
> > > method I am developing.
> > >
> > > This code snippet is from an example posted here:
> > > http://www.wackylabs.net/articles/nusoap_web_service_example_file.php
> > >
> > > I have a complex type:
> > > $server->wsdl->addComplexType(
> > >
> > >    // Name
> > >    'FileBytes',
> > >
> > >    // Type Class
> > >    'complexType',
> > >
> > >    // PHP Type
> > >    'array',
> > >
> > >    // Compositor
> > >    '',
> > >
> > >    // Restricted Base
> > >    'SOAP-ENC:Array',
> > >
> > >    array(),
> > >
> > >    array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' =>
> > > 'xsd:unsignedByte[]')),
> > >
> > >    'xsd:unsignedByte'
> > >    );
> > >
> > > For which this method is registered:
> > > $server->register('UploadFile', // method name
> > >
> > >                  // input parameters
> > >                  array('bytes' => 'tns:FileBytes', 'filename' => 
> > > 'xsd:string'),
> > >
> > >                  // output parameters
> > >                  array('return' => 'xsd:boolean'),
> > >
> > >                  // namespace
> > >                  $ns,
> > >
> > >                  // soapaction
> > >                  $ns . '#UploadFile',
> > >
> > >                  // style
> > >                  'rpc',
> > >
> > >                  // use
> > >                  'encoded',
> > >
> > >                  // documentation
> > >                  'Upload a File'
> > >    );
> > >
> > > Here is the definition of UploadFile
> > > function UploadFile($bytes, $filename) {
> > >
> > >    // Save file to specified directory using filename
> > >
> > >    $fp = fopen("upload_directory/$filename", "w");
> > >
> > >    if( is_array($bytes) ) {
> > >
> > >        foreach($bytes as $k => $v) {
> > >
> > >            fwrite($fp, $v);
> > >        }
> > >
> > >    } else {
> > >
> > >        fwrite($fp, $bytes);
> > >    }
> > >
> > >    fclose($fp);
> > >
> > > }
> > >
> > > How do I write a client to supply the UploadFile method with the
> > > binary file it needs? Is the client required to upload a file itself
> > > (using HTTP_upload.php for example) so that it has the necessary file,
> > > and then pass this file as a param to the web service UploadFile
> > > method? If you could clarify this for me that would be great.
> > >
> > > Thanks,
> > > Douglass Turner
> > > voice/sms: +354 895 5077
> > >
> > > 
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by: InterSystems CACHE
> > > FREE OODBMS DOWNLOAD - A multidimensional database that combines
> > > robust object and relational technologies, making it a perfect match
> > > for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> > > _______________________________________________
> > > Nusoap-general mailing list
> > > Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> > > https://lists.sourceforge.net/lists/listinfo/nusoap-general
> > >
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: InterSystems CACHE
> > FREE OODBMS DOWNLOAD - A multidimensional database that combines
> > robust object and relational technologies, making it a perfect match
> > for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> > _______________________________________________
> > Nusoap-general mailing list
> > Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.sourceforge.net/lists/listinfo/nusoap-general
> > 
> 
> 
> -- 
> Douglass Turner
> voice/sms: +354 895 5077
>


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8


<Prev in Thread] Current Thread [Next in Thread>