Consume a RESTful web service using PHP

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
ken4ward
Forum Newbie
Posts: 3
Joined: Tue Apr 29, 2014 11:11 am

Consume a RESTful web service using PHP

Post by ken4ward »

Very quick please. I have a RESTful service created in Java that I want to consume using PHP. I am very new to PHP and how to use it to consume web services. This is all I have so far: I just want to display the values by echoing them. This is to test that I'm able to connect successfully.

Code: Select all

<?php
	$url = 'http://localhost:8080/WMWS/webresources/entity.userregistration';
	$xml = simplexml_load_file($url);
	foreach($xml->item as $item)
	{
		echo $item;
	}
?>
your professional help is highly needed.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Consume a RESTful web service using PHP

Post by Celauran »

What errors are you encountering?
ken4ward
Forum Newbie
Posts: 3
Joined: Tue Apr 29, 2014 11:11 am

Re: Consume a RESTful web service using PHP

Post by ken4ward »

Celauran wrote:What errors are you encountering?
Not displaying any error. It displays a blank page. When i echoed a static (echo "start") content it displayed it (start).
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Consume a RESTful web service using PHP

Post by Celauran »

Check that you have error reporting enabled. Use var_dump to check that $xml contains what you'd expect.
Post Reply