java2db

How to call java SOAP web service in php ( php web service client )



SOAP Web Service is a  language independent web technology which transfer data in a XML format. So we can create a SOAP web service in java or any other programming language . In the same way we can consume it by using any programming language.

In this post , we are going to learn , how to consume or call a java JAX-WS web service in PHP .

 Basic requirements to call java SOAP web service in php :

Java SOAP Web service side :

 java (Download).

 IDE like NetBeans , Eclipse or any other (Download).

 Web/Application server like Glassfish , Tomcat , Jboss or WebSphere (Download).

 

PHP SOAP web service client (PHP consumer ) side :

 PHP server like XAMPP or WAMP (Download) .

 nuSOAP library (Download).

 

 

 

call java SOAP web service in php Process to create a Web service (Bottom up) in java :

call java SOAP web service in php Step 1 :

Create a new Dynamic web project and  package (colors). Create a class ColorWebService.java and copy the below code .

ColorWebService.java

call java SOAP web service in php Step 2:

Start the Web/Application server and deploy the project.

call java SOAP web service in php Step 3:

Now , check the WSDL file with the URL . In this example it is ,

http://localhost:8080/SimpleJavaWebService/ColorWebService?wsdl

So our java SOAP Web service is ready to use.

 

 

 

call java SOAP web service in php Process to create Soap Web Service Client in PHP :

call java SOAP web service in php Step 1 :

Create a WebServiceClient.php file in the server .

If the server is XAMPP , create in xampp\htdocs location.

If the server is WAMP , create in wamp\www location.

call java SOAP web service in php Step 2 :

Copy the below code

WebServiceClient.php

 Step 3 :

Create a folder called lib in the same location ( xampp\htdocs) .

Download , extract the nuSOAP libraries and copy to the lib folder .

call java SOAP web service in php Step 4 :

Now this is time to test our application .

call java SOAP web service in php Step 5 :

Start the PHP server (XAMPP or WAMP) .

Open any web browser and enter http://localhost/WebServiceClient.php URL .You can see the output like below.

 

call java SOAP web service in php Output :

stdClass Object ( [return] => Array ( [0] => White [1] => Black [2] => Blue [3] => Red [4] => Green [5] => Yellow [6] => Pink [7] => Orange [8] => Gray ) )

 

 

"handle Make sure, both the servers (java and PHP servers) is in running mode to call java SOAP web service in php.

 

"handle If you get any network issue , turn off the firewall settings.

 

 

 




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 create WCF web service in C# .NET ( visual studio 2013 )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java RESTful web service in PHP client
How to create a java client to call PHP SOAP web service
   [will not be published]



^ <