NuSphere Forums Forum Index
NuSphere Forums
Reply to topic


Joined: 26 Jul 2007
Posts: 14
Reply with quote
my client actually uses:

Code:
       
      // Display the result
      // echo '<h2>Result of CountBasketItems</h2><pre>';
      echo '<h2>Result of TDLRequest</h2><pre>';
      print_r($result);
      echo '</pre>';
   
   
   
      echo '<h2>Attachments</h2><pre>';
      $attachments = $client->getAttachments();
      foreach ($attachments as $a) {
         echo 'Filename: ' . $a['filename'] . "\r\n";
         echo 'Content-Type: ' . $a['contenttype'] . "\r\n";
         echo 'cid: ' . htmlspecialchars($a['cid'], ENT_QUOTES) . "\r\n";
         echo htmlspecialchars($a['data'], ENT_QUOTES);
         echo "\r\n";
      }
      echo '</pre>';   
View user's profileFind all posts by addisonpSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
I think the error happened somewhere in the call() method, right?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 26 Jul 2007
Posts: 14
Reply with quote
see the last post


Last edited by addisonp on Fri Aug 10, 2007 4:28 pm; edited 1 time in total
View user's profileFind all posts by addisonpSend private message


Joined: 26 Jul 2007
Posts: 14
Reply with quote
Okay I've resolved all the issues and would like to post how I did it, incase someone else gets into this mess:


Client Side
1. you need to include the following in your nusoap server/client

Code:
require_once('nusoap.php');
require_once('nusoapmime.php');


2. for attachments to work and you are using nusoap use the following:

Code:
$client = new soapclientmime


3. I also used the following in my client

Code:
$client->setHTTPEncoding('deflate, gzip');
$result = $client->call('Data', $Request);   // where Data is a function, see the snippets I posted for the server below for more information

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>'; print_r($result); echo '</pre>';
      echo '<h2>Attachments</h2><pre>';
      [u]$attachments = $client->getAttachments();[/u]
      foreach ($attachments as $a) {
         echo 'Filename: ' . $a['filename'] . "\r\n";
         echo 'Content-Type: ' . $a['contenttype'] . "\r\n";
         echo 'cid: ' . htmlspecialchars($a['cid'], ENT_QUOTES) . "\r\n";
         echo htmlspecialchars($a['data'], ENT_QUOTES);
         echo "\r\n";
      }
      echo '</pre>';
   }
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

}


Server side:
1. same as above

Code:
require_once('nusoap.php');
require_once('nusoapmime.php');


2. create the server

Code:
$server = new nusoapservermime;


3. register the function you are creating (remember above: "Data")

Code:
 $server->register('Data',
    array('Request'    => 'tns:Request')  );


note that I also create the Request namespace

4. create the function of course

Code:
function Data($ID,$Token,$dataArray){
....
}


5. within the function to return an attachment you need the following:

Code:
$cid = $server->addAttachment('', $filename);


And that's it.

I hope my frustration will help others get past this little hiccup
-Addison
View user's profileFind all posts by addisonpSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
great! thanks for your post.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 08 Nov 2008
Posts: 2
Reply with quote
Hi all.

I have used the example script by addisonp, but I receive this error: Response not of type text/xml: text/html; charset=latin1

Can you help me ?

Thanks.

Regards.

Luca.
View user's profileFind all posts by lcisettiSend private message
soap_parser: XML error parsing SOAP payload on line 1: Empty
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 2 of 2  

  
  
 Reply to topic