>
There are two ways to do this. The more portable (every SOAP
>
implementation should work with it) is to pass the contents of the
>
file
>
base64 encoded. The NuSOAP getfile1.php sample shows how to do it
>
this
>
way.
Hmmm... didn't really find a file called "getfile1.php".
The only thing I found was the one below (getfile1client.php).
It seems that the file calls itself, due to the last lines. So, if I
take them away, how has my client to look like?
But then the question is how the client side should look like. This
one doesn't work. Any need for a decode?
Thanks for your help!
client.php
------------------------------------------------------------------------
--------------------------
// includes nusoap classes
include('nusoap.php');
// creates an instance of the SOAP client object
$wsdl = '
http://geodata.grid.unep.ch/webservices/graph_ws.php?wsdl';
$client = new soapclient($wsdl, 'wsdl');
$result = $client->call('getFile', array('filename' => 'image.png'));
if ($client->fault) {
echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>' . htmlspecialchars($result,
ENT_QUOTES) . '</pre>';
}
}
getfile1client.php
------------------------------------------------------------------------
--------------------------
<?php
// Pull in the NuSOAP code
require_once('../lib/nusoap.php');
// Create the server instance
$server = new soap_server;
// Initialize WSDL
$server->configureWSDL('getfile1', 'urn:getfile1');
// Register the method to expose
$server->register(
'getFile', //
method name
array('filename' => 'xsd:string'), // input parameters
array('return' => 'xsd:base64Binary'), // output parameters
'urn:getfile1', // namespace
'urn:getfile1/getFile', // SOAPAction
'rpc', // style
'encoded' // use
);
// Define the method as a PHP function
function getFile($filename) {
global $HTTP_SERVER_VARS;
if ($filename != 'php.gif' && $filename != 'getfile1.php') {
return new soap_fault('SOAP-ENV:Client', 'getfile1',
'Unsupported
file name', array('filename' => $filename));
}
$handle = fopen(dirname($HTTP_SERVER_VARS['PATH_TRANSLATED']) .
'/' . $filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
return base64_encode($contents);
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: NuSoap & Binary Attachments
Scott,
thanks for the answer.
It looks as if for the second possibility (MIME) one needs the PEAR
package, right? Or what is the "ini_set" for? I don't know nothing
about PEAR, so excuse my perhaps dumb question...
Thanks a lot for your help!
Stefan
> There are two ways to do this. The more portable (every SOAP
> implementation should work with it) is to pass the contents of the
> file
> base64 encoded. The NuSOAP getfile1.php sample shows how to do it
> this
> way.
>
> The second way is to use MIME attachments. The mimeclient.php sample
> shows the client part of this. The server used for that is below.
> However, note that .NET uses DIME for attachments, not MIME, so using
> MIME knocks out a lot of interoperability.
>
> Scott Nichol
>
> <?php
> $include_path = ini_get('include_path');
> ini_set('include_path', $include_path .
> ':/home/web/s/scottnichol.com/htdocs/PEAR');
>
> require_once('../lib/nusoap.php');
> require_once('../lib/nusoapmime.php');
>
> $server = new nusoapservermime();
>
> $server->register('hello');
>
> function hello($name) {
> global $server;
> $cid = $server->addAttachment('', 'mimetest.php');
> foreach ($server->getAttachments() as $a) {
> $cid = $server->addAttachment($a['data'], $a['filename'],
> $a['contenttype']);
> }
> return new soapval('return', 'string', 'Hello, ' . $name, false,
> $this->XMLSchemaVersion);
> }
>
> $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
> $HTTP_RAW_POST_DATA :
> '';
> $server->service($HTTP_RAW_POST_DATA);
> ?>
>
> ----- Original Message -----
> From: "Stefan Schwarzer" <stefan.schwarzer@xxxxxxxxxxxx>
> To: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
> Sent: Monday, February 26, 2007 5:00 AM
> Subject: [Nusoap-general] NuSoap & Binary Attachments
>
>
>> Hi there,
>>
>> I read here and there something about the possibility to "attach"
>> graphics to the nusoap webservice. But I hardly found any information
>> about how this works in practise with nusoap. There are a couple of
>> snippets circling around, but I couldn't get them working; and I
>> haven't found a complete working example. Could someone drop in a
>> piece of code which shows how that works?
>>
>> Thanks for any hints.
>>
>> Stefan
>
>
> ----------------------------------------------------------------------
> ----------
>
>
>> ---------------------------------------------------------------------
>> ----
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to
>> share your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php?
>> page=join.php&p=sourceforge&CID=DEVDEV
>
>
> ----------------------------------------------------------------------
> ----------
>
>
>> _______________________________________________
>> Nusoap-general mailing list
>> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
>> https://lists.sourceforge.net/lists/listinfo/nusoap-general
>>
>
>
> ----------------------------------------------------------------------
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Nusoap-general mailing list
> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/nusoap-general
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Next Message by Date:
click to view message preview
Re: Basic Authentication
Indeed that was a basic test I didn't do. Anyway, the
access method
"http://user:pass@xxxxxxxxxxxxxx/HelloWorldBA.asmx?WSDL"
results in "The page cannot be displayed".
I've spoke with the ws manager and he says I should
probably use HTTP headers for basic encryption. (He is
not sure aswell). Although they are working with .NET
he has confirmed that basic auth is ON. NTLM auth is
being used in a completely diferent script.
I have no clue on what php header() arguments I must
use to send username and password. I've check HTTP1.1
specs and nothing..
Anyway shouldn't the ..
$client->setCredentials($auth_user,$auth_pass,'basic');
.. be doing the job in some way? The way I see it the
credentials should be sent before the client request
but it seems soap doesn't work like that.
Authentication before using the WS.. that makes sense.
Thanks,
Fred
--- Scott Nichol <snicholnews@xxxxxxxxxxxxxxx> wrote:
> To be sure I have this straight...
>
> When you point your browser at
> http://somedomain.org/HelloWorldBA.asmx?WSDL, it
> prompts you for a
> username and password, and you see the WSDL. When
> you use
>
http://$auth_user:$auth_pass@xxxxxxxxxxxxxx/HelloWorldBA.asmx?WSDL
> with
> that username and password from PHP, it fails.
>
> If you point your browser to
>
http://user:pass@xxxxxxxxxxxxxx/HelloWorldBA.asmx?WSDL,
> do you see the
> WSDL without being prompted? Make sure the
> user/pass is not cached by
> restarting your browser first.
>
> Are you sure the site uses basic authentication?
> Since it is
> implemented on .NET, NTLM authentication may be what
> it is actually
> using.
>
> Scott Nichol
>
> ----- Original Message -----
> From: "fred lixo" <radiolixo@xxxxxxxxx>
> To: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, March 29, 2007 12:36 PM
> Subject: [Nusoap-general] Basic Authentication
>
>
> > Hello,
> >
> > I was not sure if I should post this message in a
> php
> > forum rather than here but hope some of you can
> help
> > allthesame.
> >
> > I looked for Basic Authentication code snippets
> and
> > nusoap docs and I'm trying to consume a WS like
> below.
> > If I access the wsdl link directly I get prompted
> for
> > user and pass and I can view the contents. Using
> the
> > script I'm getting the error at msg bottom. I
> can't
> > figure out what is wrong. Help?
> >
> > Finally but not least, thank you Scott for the iwa
> > subject answer.
> >
> > Best Regards,
> > Fred
> >
> > ------------------
> > #### PHP Code ####
> > ------------------
> > <?php
> > require_once("nusoap/nusoap.php");
> > $auth_user = "some_user";
> > $auth_pass = "some_pass";
> >
> > // also tried
> > //
> >
>
$wsdl="http://$auth_user:$auth_pass@xxxxxxxxxxxxxx/HelloWorldBA.asmx?WSDL";
> > // but does not work
> >
>
$wsdl="http://somedomain.org/HelloWorldBA.asmx?WSDL";
> >
> > $client = new soapclient($wsdl,'wsdl');
> > print $client->getError();
> >
>
$client->setCredentials($auth_user,$auth_pass,'basic');
> > $proxy = $client->getProxy();
> > ?>
> >
> > ------------------------
> > #### ERROR MESSAGES ####
> > ------------------------
> > wsdl error: HTTP ERROR: HTTP authentication failed
> >
> > Parse error: syntax error, unexpected T_STRING in
> > D:\files\nusoap\nusoap.php(6983) : eval()'d code
> on
> > line 1
> >
> > Fatal error: Class 'soap_proxy_14521' not found in
> > D:\files\nusoap\nusoap.php(6985) : eval()'d code
> on
> > line 1
> >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > The fish are biting.
> > Get more visitors on your site using Yahoo! Search
> Marketing.
> >
>
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
> >
> >
>
-------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of
> IT
> > Join SourceForge.net's Techsay panel and you'll
> get the chance to
> > share your
> > opinions on IT & business topics through brief
> surveys-and earn cash
> >
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Nusoap-general mailing list
> > Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> >
>
https://lists.sourceforge.net/lists/listinfo/nusoap-general
> >
>
>
>
-------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get
> the chance to share your
> opinions on IT & business topics through brief
> surveys-and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Nusoap-general mailing list
> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
>
https://lists.sourceforge.net/lists/listinfo/nusoap-general
>
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Previous Message by Thread:
click to view message preview
Re: NuSoap & Binary Attachments
Scott,
thanks for the answer.
It looks as if for the second possibility (MIME) one needs the PEAR
package, right? Or what is the "ini_set" for? I don't know nothing
about PEAR, so excuse my perhaps dumb question...
Thanks a lot for your help!
Stefan
> There are two ways to do this. The more portable (every SOAP
> implementation should work with it) is to pass the contents of the
> file
> base64 encoded. The NuSOAP getfile1.php sample shows how to do it
> this
> way.
>
> The second way is to use MIME attachments. The mimeclient.php sample
> shows the client part of this. The server used for that is below.
> However, note that .NET uses DIME for attachments, not MIME, so using
> MIME knocks out a lot of interoperability.
>
> Scott Nichol
>
> <?php
> $include_path = ini_get('include_path');
> ini_set('include_path', $include_path .
> ':/home/web/s/scottnichol.com/htdocs/PEAR');
>
> require_once('../lib/nusoap.php');
> require_once('../lib/nusoapmime.php');
>
> $server = new nusoapservermime();
>
> $server->register('hello');
>
> function hello($name) {
> global $server;
> $cid = $server->addAttachment('', 'mimetest.php');
> foreach ($server->getAttachments() as $a) {
> $cid = $server->addAttachment($a['data'], $a['filename'],
> $a['contenttype']);
> }
> return new soapval('return', 'string', 'Hello, ' . $name, false,
> $this->XMLSchemaVersion);
> }
>
> $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
> $HTTP_RAW_POST_DATA :
> '';
> $server->service($HTTP_RAW_POST_DATA);
> ?>
>
> ----- Original Message -----
> From: "Stefan Schwarzer" <stefan.schwarzer@xxxxxxxxxxxx>
> To: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
> Sent: Monday, February 26, 2007 5:00 AM
> Subject: [Nusoap-general] NuSoap & Binary Attachments
>
>
>> Hi there,
>>
>> I read here and there something about the possibility to "attach"
>> graphics to the nusoap webservice. But I hardly found any information
>> about how this works in practise with nusoap. There are a couple of
>> snippets circling around, but I couldn't get them working; and I
>> haven't found a complete working example. Could someone drop in a
>> piece of code which shows how that works?
>>
>> Thanks for any hints.
>>
>> Stefan
>
>
> ----------------------------------------------------------------------
> ----------
>
>
>> ---------------------------------------------------------------------
>> ----
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to
>> share your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php?
>> page=join.php&p=sourceforge&CID=DEVDEV
>
>
> ----------------------------------------------------------------------
> ----------
>
>
>> _______________________________________________
>> Nusoap-general mailing list
>> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
>> https://lists.sourceforge.net/lists/listinfo/nusoap-general
>>
>
>
> ----------------------------------------------------------------------
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Nusoap-general mailing list
> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/nusoap-general
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Next Message by Thread:
click to view message preview
Re: Sample apps hang "Waiting for localhost"
Yes, you will have to alter all of them. I will update the samples soon
so that they use the nusoapclient class that works even when PHP 5 SOAP
support is present.
Scott Nichol
----- Original Message -----
From: "Peter Bradley" <P.Bradley@xxxxxxxxxxxxx>
To: "Peter Bradley" <P.Bradley@xxxxxxxxxxxxx>
Cc: <nusoap-general@xxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, February 22, 2007 5:26 PM
Subject: Re: [Nusoap-general] Sample apps hang "Waiting for localhost"
> Ysgrifennodd Peter Bradley:
> <snip />
>> The code now gets past the require_once() line, but then
>> hangs on the line:
>>
>> $client = new soapclient("http://soap.amazon.com/onca/soap2", false,
>> $proxyhost, $proxyport, $proxyusername,
>> $proxypassword);
>>
>> The application hangs on every one of the samples that I try. Can
>> anyone help?
>>
>
> Sorry to follow up on my own post. I think I've made some progress.
> Firstly I altered the offending line to read:
>
> $client = new soapclient2("http://soap.amazon.com/onca/soap2", false,
> $proxyhost, $proxyport, $proxyusername, $proxypassword);
>
> Then I remembered to alter the constructor name for soapclient2 in
> nusoap.php (I know, d'uh!). The result was that I got back a SOAP
> fault
> saying:
>
> "We encountered an error while processing your request. Please make
> sure that you are using a valid
> developer token and that you have developer token and that you have
> registered for this service.
> For more information, please visit http://www.amazon.com/webservices"
>
> Clearly I haven't registered, so I guess this is OK.
>
> Does this mean that I have to alter all the clients in the same way?
> Is there an occasion when
> I should create a soapclient object rather than a soapclient2 object?
>
> Thanks.
>
>
> Peter
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Nusoap-general mailing list
> Nusoap-general@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/nusoap-general
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV