Jump to content

PHP - SOAP


starkec

Recommended Posts

Hey guys,

I'm trying to use PHP and nuSOAP to send information from my form to this web service on directTrack. The web service even gives me details on what the web service needs from the soap: http://secure.directtrack.com/api/soap.php# (its the addAffiliate one listed). So this gives the SoapAction, endpoint, etc.

 

I have this code below, but I can't seem to get it working. Am I in the right direction?

 

<?php

require_once('lib/nusoap.php');

 

$endpoint = 'http://secure.directtrack.com/api/soap.php';

$namespace = 'http://soapinterop.org//';

$soapAction = 'http://secure.directtrack.com/api/soap.php/addAffiliate';

 

// Build our paremeter array

$FIELDS = array();

 

$FIELDS['client'] = 'testing';

$FIELDS['password'] = 'test';

$FIELDS['email'] = $_POST['email'];

$FIELDS['first_name'] = $_POST['first_name'];

$FIELDS['last_name'] = $_POST['last_name'];

$FIELDS['company'] = $_POST['company'];

$FIELDS['pwd'] = $_POST['pwd'];

$FIELDS['address'] = $_POST['address'];

$FIELDS['address2'] = $_POST['address2'];

$FIELDS['city'] = $_POST['city'];

$FIELDS['state'] = $_POST['state'];

$FIELDS['country'] = $_POST['country'];

$FIELDS['zip'] = $_POST['zip'];

$FIELDS['phone'] = $_POST['phone'];

$FIELDS['fax'] = $_POST['fax'];

$FIELDS['tax_id'] = $_POST['tax_id'];

$FIELDS['website'] = $_POST['website'];

$FIELDS['website2'] = $_POST['website2'];

$FIELDS['website3'] = $_POST['website3'];

 

$soap = new soapclient($endpoint, 'wsdl');

$result = $soap->call('addAffiliate', array('parameters' => $FIELDS), $namespace, $soapAction);

 

echo "request: ".$client->request;

if ($client->fault) {

      echo "SOAP error: ".$result['faultstring'];

        print_r($result);

} else {

      $err = $client->getError();

      if ($err) {

                echo "SOAP error: ".$err;

        }

        else {

                print_r($result);

}

}

 

 

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/72376-php-soap/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.