homepage Welcome to WebmasterWorld Guest from 23.22.59.252
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP + Soap
nickCR

5+ Year Member



 
Msg#: 4136098 posted 6:43 pm on May 20, 2010 (gmt 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... :(

 

Little_G

5+ Year Member



 
Msg#: 4136098 posted 10:53 pm on May 29, 2010 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved