Welcome to WebmasterWorld Guest from 54.234.38.8

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP + Soap

     
6:43 pm on May 20, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:May 29, 2007
posts:73
votes: 0


Hi Guys,

I need to make a request to a SOAP web service but it is not giving me the result I want.

I'm trying to call an ASPX web service here:

[indicadoreseconomicos.bccr.fi.cr...]

I have tried using the new SoapClient('url to wsdl');

[indicadoreseconomicos.bccr.fi.cr...]

I'm trying to use this code that I found on php.net but it's not receiving a response:


$soapClient = new SoapClient($this->soapBCCR);

/*

// Prepare SoapHeader parameters
$sh_param = array(
'tcIndicador'=> '317',
'tcFechaInicio'=> '18/05/2010',
'tcFechaFinal'=> '18/05/2010',
'tcNombre'=> 'Anyone',
'tcSubNiveles'=> 'N');
$headers = new SoapHeader('http://indicadoreseconomicos.bccr.fi.cr/IndicadoresEconomicos/WebServices/wsIndicadoresEconomicos.asmx','ObtenerIndicadoresEconomicosXML');

// Prepare Soap Client
$soapClient->__setSoapHeaders(array($headers));

*/

// Setup the RemoteFunction parameters
$ap_param = array(
'tcIndicador'=> '317',
'tcFechaInicio'=> '18/05/2010',
'tcFechaFinal'=> '18/05/2010',
'tcNombre'=> 'TicoVista',
'tcSubNiveles'=> 'N');

// Call RemoteFunction ()
$error = 0;
try {
$info = $soapClient->__call("ObtenerIndicadoresEconomicosXML", array($ap_param));
} catch (SoapFault $fault) {
$error = 1;
print("
alert('Sorry, blah returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring.". We will now take you back to our home page.');
");
}

if ($error == 0) {
$auth_num = $info->RemoteFunctionResult;

if ($auth_num < 0) {
//var_dump($info);

// Kill the link to Soap
unset($soapClient);
}
}



I'm getting the following error:

Sorry, blah returned the following ERROR: soap:Server-Server was unable to process request. ---> Object reference not set to an instance of an object.. We will now take you back to our home page.

Can someone please point me in the right direction? I'm lost... :(
10:53 pm on May 29, 2010 (gmt 0)

Preferred Member

10+ Year Member

joined:Feb 11, 2006
posts:481
votes: 0


Hi,

This works for me (replace example.com with correct domain):
$soapClient = new SoapClient('http://example.com/IndicadoresEconomicos/WebServices/wsIndicadoresEconomicos.asmx?wsdl');

// Setup the RemoteFunction parameters
$ap_param = array(
'tcIndicador'=> '317',
'tcFechaInicio'=> '18/05/2010',
'tcFechaFinal'=> '18/05/2010',
'tcNombre'=> 'TicoVista',
'tnSubNiveles'=> 'N');

// Call RemoteFunction ()
try {
$info = $soapClient->ObtenerIndicadoresEconomicosXML($ap_param);
echo $info->ObtenerIndicadoresEconomicosXMLResult;
} catch (SoapFault $fault) {
echo $fault;
}


For tnSubNiveles you had tcSubNiveles which is what I think was causing your error.

Andrew