Using SOAP with PHP5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Using SOAP with PHP5

Post by hsharma12 »

Hi All,

I am trying to access to a WSDL library using PHP5 soap extension. I am able to connect to the SOAP server and able to get the list of all the wsdl functions from the soap server. this means that I am successfully able to connect to the server however when I try to get access to the acrual library function using soapclient object, program takes forever and script halts after 30 mins.

Error that i get is as listed below.

Fatal error: Maximum execution time of 30 seconds exceeded in D:\wamp\www\test\testsoap.php on line 12


Any help or suggestions are highly appreciated.

Thanks,
Hariom
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post your code.
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

feyd wrote:Post your code.

Code: Select all

<?
$client = new SoapClient(
"http://pharmatest01.safe-med.com:24088/safemed/ws");
echo "<br>Answer here";
print_r($client->__getFunctions());  // Able to print all the functions from the wsdl
$result = $client->regimenRouteList(); // Script hangs forever here.
?>

Here is my code.. Thanks for your interest.
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

function "regimenRouteList" requires a parameter of type regimenRouteList
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

Code: Select all

<?
$client = new SoapClient(
"http://pharmatest01.safe-med.com:24088/safemed/ws");
//print_r($client->__getFunctions());
//echo "<br>Types here";
//print_r($client->__getTypes());

$params = array(
    'description'    => 'lipitor',
    'threshold'        => 500,
    'flags'        => 1
  );
 $result = $client->dispensableMedListByDescription($params);
?>
I have changed the function call to a new function with the required parameter passed. But still it has the same output.

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\htdocs\test\testSoap.php on line 14
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please try again with

Code: Select all

<?php
ini_set('default_socket_timeout', 5);
$client = new SoapClient("http://pharmatest01.safe-med.com:24088/safemed/ws", array('connection_timeout'=>5.0));

$params = array(
    'description'    => 'lipitor',
    'threshold'        => 500,
    'flags'        => 1
  );
$result = $client->dispensableMedListByDescription($params);
?>
also take a closer look at
http://pharmatest01.safe-med.com:24088/safemed/ws wrote:<soap:address location="http://safe-med.com:4088/safemed/ws"/>
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

Thanks Volka for your reply.

I tried with your suggestions but this time I got a fatal error as mentioned below.

Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\Program Files\Apache Group\Apache2\htdocs\test\testSoap.php:13 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://safe-med...', 'dispensableMedL...', 1, 0) #1 [internal function]: SoapClient->__call('dispensableMedL...', Array) #2 C:\Program Files\Apache Group\Apache2\htdocs\test\testSoap.php(13): SoapClient->dispensableMedListByDescription(Array) #3 {main} thrown in C:\Program Files\Apache Group\Apache2\htdocs\test\testSoap.php on line 13

Please review and suggest accordingly.

Once again thanks to all the guys putting efforts for me.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

volka wrote:also take a closer look at
http://pharmatest01.safe-med.com:24088/safemed/ws wrote:<soap:address location="http://safe-med.com:4088/safemed/ws"/>
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

Volka,

This wsdl URL is fine. I had a look on that. Also I would like to mention that this URL works fine when I try to connect with this using CURL. I am not sure why is this creating the problem with PHP5.


Also, we can change the port no 8088 if you want to check.

Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

4088
24088
sure?
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

Yes..its sure. This URL works fine if you put this directly in the address bar of the browser. It will list out the complete wsdl in front of you. :-)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Yes, it returns the wsdl if you connect to 24088. But the wsdl informs the client to connect to the port 4088. That's 24088 minus 20000.
Are you sure sure sure that is correct? I think it is not.
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

hsharma12, as Volka suggested the end-point for the Webservice is unreachable. double check with the Webservice provider.
hsharma12
Forum Newbie
Posts: 7
Joined: Sun Sep 30, 2007 5:33 am

Post by hsharma12 »

Volga, Oh..Thats definately not correct. It needs to connect to 24088 only..But why does it minus 2000 from that?

I also used 8088 (Web service provider also provides info on this port) but it does not work.

PLease suggest.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

But why does it minus 2000 from that?
It says so in the wsdl file
Post Reply