Home  >  Article  >  Backend Development  >  PHP uses NuSoap to generate webservice and combine it with WSDL to call asp.net_PHP tutorial

PHP uses NuSoap to generate webservice and combine it with WSDL to call asp.net_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:46:50961browse

 

  1. require_once("nusoap-0.9.5/lib/nusoap.php");     
  2. //Define service program                                                                                             
  3. function Add($a,$b)  
  4. {  
  5.       return $a+$b;  
  6. }
  7. //Initialize the service object, which is an instance of class soap_server
  8. $soap = new soap_server;
  9. //Call the register method of the service object to register the program that needs to be accessed by the client.   
  10. //Only registered programs can be accessed by remote clients.     
  11. $soap->configureWSDL('EventWSDL''http://tempuri.org/');  
  12. $soap->register('Add',  array("a"=>"xsd:string","b"=>"xsd:string"), // Definition of input parameters
  13. array("return"=>"xsd:string") //Definition of return parameters
  14. ); 
  15. //The last step is to pass the data submitted by the client through post method to the service method of the service object.
  16. //The service method processes the input data, calls the corresponding function or method, and generates correct feedback and sends it back to the client.     
  17. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';    
  18. $soap->service($HTTP_RAW_POST_DATA);    
  19. ?>   

asp.net call

view plain
  1. lt.EventWSDL new =new webserviceTest.lt.EventWSDL();  
  2.        Response.Write(ew.Add("1","7").ToString()); 


=================================

Reference:

Use NuSOAP combined with WSDL to program
Category: PHP Comments: 0 Views: 513 Publication time: 2009-09-10 16:59:38
From:http://www.scottnichol.com/nusoapprogwsdl.htm

This article follows the three articles Introduction to NuSOAP, Programming with NuSOAP and Programming with NuSOAP Part 2, adding some examples to illustrate how to use NuSOAP combined with WSDL to create and use SOAP web services.

Hello, World Redux
The New Client
Defining New Data Structures

Hello, World Redux

I used the common "Hello, World" instance in Introduction to NuSOAP. In that article, I demonstrated client-side and server-side request and response interactions. Here, I'll extend that instance using WSDL.

The WSDL file provides the metadata for the service, and NuSOAP allows the programmer to specify the WSDL created by the service using additional fields and methods of the soap_server class.

The Service's code must do many things in the order in which the correct WSDL is generated. The information of the service is specified by calling the configureWSDL method. The information of each method is also specified by providing additional parameters of the register method. The service code using WSDL is demonstrated in the following example:
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello',           // method name

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn