How to access php web service in dot net windows application(Hello world application)
- Create new folder and rename it to "server" on your server space
- ( local user just create in htdocs. )
- Download Nusoap library from http://sourceforge.net/projects/nusoap/ it is zip file.You have to extract the "lib" folder from it and paste to web root(I.E htdocs).
- Now create new php file in sever folder and rename it to "server.php"
- Paste the following code in it.
server.php
//include required class for build nnusoap web service server
require_once('../lib/nusoap.php');
// Create server object
$server = new soap_server();
// configure WSDL
$server->configureWSDL('hello world', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello_world', // method
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello world to client' // documentation
);
// Define the method as a PHP function
function hello_world($pName) {
return 'Hello world from, ' . $pName;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
1.Open Visual Studio and create Windows Froms Application
(File->New->Project->Windows->Windows Forms Application).
2.Now Create label (Tools->Label ) name it to "lblname"
3.Now create textbox(Tools->TextBox) renamed it to "Txtname".
4.Now Create button (Tools->Button) renamed it to "btn_call_web_service_1"
5.Add Web Service Reference( Right click on your project and click on Add service Reference)
6.Service window will open now click on "Advance button located at bottom"
7.Service Reference Setting window will open Click on "Add Web Reference" button at bottom.
8.Now Add Web Reference window will open Enter server url
http://localhost:8080/webservice/nusoap/server/server.php?wsdl and click on "Go"
9.Now the services founds is displayed on window enter name of web service as "hello_world_from_php" and click on " Add Reference " button.
10.Now Double Click on call web service button created on form.
11.Code Window will open
12.Paste the bellow code and run application Your web service is now worked
(File->New->Project->Windows->Windows Forms Application).
2.Now Create label (Tools->Label ) name it to "lblname"
3.Now create textbox(Tools->TextBox) renamed it to "Txtname".
4.Now Create button (Tools->Button) renamed it to "btn_call_web_service_1"
5.Add Web Service Reference( Right click on your project and click on Add service Reference)
6.Service window will open now click on "Advance button located at bottom"
7.Service Reference Setting window will open Click on "Add Web Reference" button at bottom.
8.Now Add Web Reference window will open Enter server url
http://localhost:8080/webservice/nusoap/server/server.php?wsdl and click on "Go"
9.Now the services founds is displayed on window enter name of web service as "hello_world_from_php" and click on " Add Reference " button.
10.Now Double Click on call web service button created on form.
11.Code Window will open
12.Paste the bellow code and run application Your web service is now worked
Dim webservice As New hello_world_from_php.helloworld
MsgBox(webservice.hello_world(txtname.Text))
Loading...
|
Comments :
Post a Comment