java2db

How to call PHP RESTful web service in java client



To call PHP RESTful web service in java client , first create a simple  PHP restful web service .Later create a java class (client) to call the service .

 

How to call PHP RESTful web service in java client Basic requirements to create a PHP RESTful web service :

XAMPP server (click here to download ).

 

How to call PHP RESTful web service in java client Steps to create PHP RESTful web service :

How to call PHP RESTful web service in java client Step 1 :

create .php files in web server location (Example : For XAMPP server , create at htdocs folder).

To view the directory structure, you can use the Eclipse for PHP . So the directory structure looks like below.

 

How to call PHP RESTful web service in java client Step 2 :

Copy the below code to functions.php and restfulPHP.php .
functions.php

restfulPHP.php 

 

How to call PHP RESTful web service in java client Step 3 :

Run the php web server (XAMPP ).

 

How to call PHP RESTful web service in java client Step 4 :

Test the service using any web browser with the below URL.

http://localhost/phpServiceExe/restfulPHP.php?wonderName=Taj%20Mahal

http://  represents the http protocol

localhost  is the local machine IP (127.0.0.1)

phpServiceExe is the folder that we created in  the htdocs.

restfulPHP.php is the php file name (PHP service file)

wonderName is the parameter name.

Taj%20Mahal  is the value.

 

Now we can call this service in java through the URL.

 

 

How to call PHP RESTful web service in java client Steps to call PHP RESTful web service in java client :

How to call PHP RESTful web service in java client Step 1 :

Create a dynamic Web project in Eclipse or NetBeans IDE.

 

How to call PHP RESTful web service in java client Step 2 :

Crate a package (Ex : restfulJavaClientForPHPwebservice) and a java class (Ex : javaClientForPHPService.java) .

 

How to call PHP RESTful web service in java client step 3 :

Extract and add the Jersey jar files to the lib folder . So the entire directory structure as follows .

 

 

How to call PHP RESTful web service in java client Step 4 :

Copy the below code in javaClientForPHPService.java file

 

How to call PHP RESTful web service in java client Step 5 :

Run the java class , the result should be like below.

 

call java RESTful web service in PHP client Make sure that the PHP web server is in running mode to call PHP RESTful web service in java client.



Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in PHP SOAP client
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call java RESTful web service in PHP client
How to create a java client to call PHP SOAP web service
How to create PHP RESTful web service and client with example
How to call java SOAP web service in php ( php web service client )
   [will not be published]



^ <