RE: [SOAP] SOAP PEAR Module - Array Issues

[email protected] ("Ross King II")
Newsgroups php.soap
Message-ID <000301c8cabd$a86ffb80$f94ff280$@[email protected]>
Thanks

I guess the Pear SOAP Has issues as this would not work w/ PHP 4.2 @ PEAR. Your example did not work as posted but your guidance and a modification of the arrays and the WSDL does its job.

Thanks, I have posted the modified code as an example of what works with this WSDL.


CODE --

<?php

error_reporting(E_ALL);

// Do not cache the WSDL file <- good for developing/bad for production $ini = ini_set("soap.wsdl_cache_enabled","0");


try {
	$options = array(
		'trace' => true,
		'exceptions' => true,
		'soap_version' => SOAP_1_1
	);

	$client = new SoapClient("http://api.emaildirect.com/v3/api.asmx?WSDL", $options);
	//print_r($client);

        // Build the parameters
	$parameter = array(
		'AccountName' => 'UserName',
		'APIPassword' => 'Password',
		'Email' => '[email protected]',
		'SourceID' => '1',
		'PublicationIDs' => array(2,3),
		'ListIDs' => array(2,3),
		'AutoResponderID' => '0',
		'CustomFields' => array(array('FieldName' => 'FirstName', 'Value' => 'Ross'),array('FieldName' => 'LastName', 'Value' => 'Ross'))
	);
        // Call the Email Force Addition function
	$client->Email_ForceAddition($parameter);

        // Shows the Request and Response in XML
	echo("<br />REQUEST :<br />" .
		htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .
		htmlspecialchars($client->__getLastResponse()) . "<br />");
}
catch (SoapFault $ex) { // Catch any errors and do appropriate debugging
	echo "Error:<br />" . nl2br($ex->faultcode) . '<br /><br />';
	echo 'Error Details:<br />'. nl2br($ex->faultstring) . '<br />';
	echo("<br />REQUEST :<br />" .
		htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .
		htmlspecialchars($client->__getLastResponse()) . "<br />");
}
?>

-----Original Message-----
From: Jeffery Fernandez [mailto:[email protected]] 
Sent: Monday, June 09, 2008 9:17 PM
To: [email protected]
Subject: Re: [SOAP] SOAP PEAR Module - Array Issues

Ross,

try the example shown below. I am not using PEAR soap library but the standard PHP library:

<?php

error_reporting(E_ALL);

// Do not cache the WSDL file <- good for developing/bad for production $ini = ini_set("soap.wsdl_cache_enabled","0");


try {
	$options = array(
		'trace' => true, 
		'exceptions' => true, 
		'soap_version' => SOAP_1_1
	);
	
	$client = new SoapClient("http://api.emaildirect.com/v3/api.asmx?WSDL", $options);
	//print_r($client);
	
        // Build the parameters
	$parameter = array(
		'AccountName' => 'test',
		'APIPassword' => '123456',
		'Email' => '[email protected]',
		'SourceID' => '',
		'PublicationIDs' => array(array('int' => 2), array('int' => 3)),
		'ListIDs' => array(array('int' => 2), array('int' => 3)),
		'AutoResponderID' => '',
		'CustomFields' => array(
			array('CustomField' => 
				array('FieldName' => '', 'Value' => '')
			)
		)
	);	
        // Call the Email Force Addition function
	$client->Email_ForceAddition($parameter);
	
        // Shows the Request and Response in XML
	echo("<br />REQUEST :<br />" . 
		htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .
		htmlspecialchars($client->__getLastResponse()) . "<br />");	
}
catch (SoapFault $ex)  // Catch any errors and do appropriate debugging {
	echo "Error:<br />" . nl2br($ex->faultcode) . '<br /><br />';
	echo 'Error Details:<br />'. nl2br($ex->faultstring) . '<br />';
	echo("<br />REQUEST :<br />" . 
		htmlspecialchars($client->__getLastRequest()) . "<br />");
	echo("<br />RESPONSE:<br />" .
		htmlspecialchars($client->__getLastResponse()) . "<br />");	
}
?>

They above should work provided you give the right Account name and API Password.

cheers,
Jeffery Fernandez

On Fri, 6 Jun 2008 06:14:22 am Ross King II wrote:
> I am using the SOAP Package and have an issue.
>
[snip]



--
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia
web: http://www.ivt.com.au
phone: +61 3 9723 9399
fax: +61 3 9723 4899
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.