Php soap server C # Client

Source: Internet
Author: User

Recently I wrote a php soap server that can call the PHP client, but cannot call the c # client. After reading the manual, I have not accessed it for a long time, finally, I tried NuSOAP.
An open-source project on SF.net has good results, and Eacy implements the required functions.
C # web Services (server) are very easy to implement, and C # client calls are also very convenient.
The web server of PHP generally generates a. wsdl file, which is a service provided by an Xml file description.
Let's take a look at my first PHP web service.
<? Php
/**
* ProcessSimpleType method
* @ Param string $ who name of the person we'll say hello
* @ Return string $ helloText the hello string
*/
Function ProcessSimpleType ($ who ){
Return "Hello $ who, welcome to http://www.my400800.cn ";";
}
?>
Remember to download nusoaphttp: // www.bkjia.com/uploadfile/2011/0825/20110825031745407.zip

<? Php
Require_once ("lib/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


Click "wsdl" next to view the provided services, as shown in figure


 

 

 

C # Call Code


Private void button#click (object sender, EventArgs e ){
SimpleService svc = new SimpleService ();
String s = svc. ProcessSimpleType ("400 phone VIP user ");
MessageBox. Show (s );
}
Result

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.