I’m trying to use a SOAP API with nusoap but am having some real problems with it. I’ve never used SOAP before (nor have I used NUSOAP either) and would be grateful for any help please.
This is the page I’m using to help me: http://api.dotmailer.com/v2/api.svc#op.ApiService.GetAddressBooks and this is what I’m using this to get the results:
<?php
# initialise
$username='username@apiconnector.com';
$password='password';
$error_message1="Something went wrong with client ";
$error_message2="Something went wrong with proxy ";
$error_message3="Something went wrong with result 1st ";
$error_message4="Something went wrong with result 2nd ";
$error_message5="Something went wrong with result 3rd ";
$wsdlPath = "https://apiconnector.com/v2/api.svc?wsdl";
# perform lookup
require $INSTALL['include']."/nusoap/lib/nusoap.php";
$client=new soapclient( $wsdlPath,'wsdl' );
$err=$client->getError();
if( $err ) { echo $error_message1; exit( $err ); }
# create a proxy client.
$proxy=$client->getproxy();
$err=$proxy->getError();
if( $err ) { echo $error_message2; exit( $err ); }
# call the SOAP method for GetAddressBooks.
$result=$proxy->GetAddressBooks( $username,$password );
if( $proxy->fault ) {
echo $error_message3;
} else {
$err=$proxy->getError();
if( $err ) {
echo $error_message4; exit( $err );
} else {
if( $result['error_code']!='0' ){
echo $error_message5; exit( $err );
}
GetAddressBooksResult( $result );
}
}
?>
That just outputs this Something went wrong with result 2nd wsdl error: phpType is struct, but value is not an array: see debug output for details.
From the output I can see that the problem is here if( $err ) {
echo $error_message4; exit( $err ); but I don’t know how to fix that.