This article is mainly on the PHP call Java WebService Simple example of the introduction, the need for friends can come to the reference, I hope to help you.
Use PHP to invoke the Java language development webservice. The client submits two string parameters, and the service side returns an object type. The service side uses AXIS-1.4 as the SOAP engine. The client is PHP5.2.9, using Nusoap as the SOAP engine. Server object class code is as follows: Import java.io.Serializable; public class Person implements Serializable { /** * &N Bsp */ Private static final long serialversionuid = -410186774891162281l; Private String username; private int age; Private Boolean sex;//true:male;false:female public String GetUserName () { &nbs P return username; } public void Setusername (String username) { This.username = Username; } public int getage () { return age; } public void setage (int age) { this.age = age; } Public Boolean getsex () { return sex : public void Setsex (Boolean sex) { this.sex = sex; }} service class code is as follows: public Class Userlogin { public person login (string loginName, String loginpasswd) { &N Bsp Person Aperson = new person (); if (loginname.equals ("Laoli") && loginpasswd.equals ("111111")) { Aperson.setusername ("Lao Li"); Aperson.setage (55); Aperson.setsex (true); } else if (Loginname.equals ("Xiaoli") && loginpasswd.equals ("123456")) { Aperson.setusername ("Xiaoli"); Aperson.setage (23); Aperson.setsex (false); } else { Aperson = null; } return Aperson; } } client code is as follows: <?php / * Created on 2011-10-12 * Author Wan Ghao * * package_name/userloginclient.php */header ("Content-type:text/html;charset=utf-8"); Pull in the Nusoap code require_once ("libs/nusoap.php"); Create the client instance $client = new Nusoapclient (' http://localhost:8080/axis/services/UserLoginWS?wsdl ', true); $client->soap_defencoding = ' utf-8 '; $client->decode_utf8 = false; $client->xml_encoding = ' utf-8 '; Check for an error $err = $client->geterror (); if ($err) { /Display the error echo ' <h2>constructor error</h2><pre> '. $e Rr. ' </pre> '; //at ' This point ', you know the ' call ' follows'll fail}//Call the SOAP method $param =arRay (' LoginName ' => ' Laoli ', ' loginpasswd ' => ' 111111 '); $result = $client->call (' login ', $param); Check for a fault if ($client->fault) { echo ' <h2>Fault</h2><pre> '; PR Int_r ($result); echo ' </pre> '; else { /Check for errors $err = $client->geterror (); if ($err) { & nbsp /Display the error echo ' <h2>Error</h2><pre> '. $err. ' </pre> '; } else { //Display The result Echo ' <h2>resul T</h2><pre> '; Print_r ($result); echo ' </pre> '; } echo ' <br> '; $param =array (' loginName ' => ' Xiaoli ', ' loginpasswd ' => ' 123456 '); $result = $client->call (' login ', $param); Check for a fault if ($client->fault) { echo ' <H2>fault</h2><pre> '; Print_r ($result); echo ' </pre> '; else { /Check for errors $err = $client->geterror (); if ($err) { & nbsp /Display the error echo ' <h2>Error</h2><pre> '. $err. ' </pre> '; } else { //Display The result Echo ' <h2>resul T</h2><pre> '; Print_r ($result); echo ' </pre> '; }}?>