PHP SOAP server-side C# client_PHP tutorial

WBOY
Release: 2016-07-13 17:45:05
Original
888 people have browsed it

Recently I wrote a SOAP server for PHP, which enabled the calling of the PHP client, but could not realize the calling of the c# client. After reading the manual, I searched for it for a long time but could not access it. Finally, I tried NuSOAP
An open source project on SF.net, the effect is very good, Eacy can achieve the required functions
C# web services (server-side) are very easy to implement, and C# client calls are also very convenient
PHP's web server generally generates a .wsdl file. .wsdl is an Xml file describing the services provided
Let’s take a look at my first PHP web service
/**
* ProcessSimpleType method
* @param string $who name of the person we'll say hello to
* @return string $helloText the hello   string
*/
function ProcessSimpleType($who) {
Return "Hello $who, Welcome to visit http://www.my400800.cn ";";
}
?>
Remember to download nusoap firsthttp://www.BkJia.com/uploadfile/2011/0825/20110825031745407.zip

require_once("lib/nusoap/nusoap.php");
$namespace = "http://www.my400800.cn";
// create a new soap server
$server = new soap_server();
// configure our WSDL
$server->configureWSDL("SimpleService");
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register our WebMethod
$server->register(
// method name:
'ProcessSimpleType',
// parameter list:
array('name'=>'xsd:string'),
// return value(s):
array('return'=>'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style. rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'A simple Hello World web method');

// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>
You can use it after writing it
Open .net and add reference


Next click wsdl, you can see the services provided, as shown below


PHP SOAP server-side C# client_PHP tutorial

PHP SOAP server-side C# client_PHP tutorial

PHP SOAP server-side C# client_PHP tutorial

C# calling code


private void button1_Click(object sender, EventArgs e) {
SimpleService svc = new SimpleService();
string s = svc.ProcessSimpleType("400 phone VIP user");
MessageBox.Show(s);
}
Result

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478679.htmlTechArticleI recently wrote a PHP SOAP server, which realizes the calling of the PHP client, but cannot realize the calling of the c# client. After reading the manual and looking for it for a long time, I still couldn’t access it. I finally tried it...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!