how to call php web service called .net

Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery


Here is solution how to access php web service in dot net windows application(Hello world application)


Please make little donation if you are like my hard work
 


  1.  Create new folder and rename it to "server" on your server space
  2. ( local user just create in htdocs. )
  3.  Download Nusoap library from 
  4. nusoap it is zip file
  5. You have to extract the "lib" folder from it and paste to web root(I.E htdocs).
  6.  Now create new php file in sever folder and rename it to "server.php"
  7. Paste the following code in it.
  8. 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); 
    
Now Client Side (VB.NET) Steps:


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
 
Dim webservice As New hello_world_from_php.helloworld
  MsgBox(webservice.hello_world(txtname.Text))

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

15 comments:

Anonymous said...

thanks very much, it's really help me

Sebastien. said...

That is a nice piece of code.

Very simple, very usefull.

Thanks for sharing.

Anonymous said...

Thanks! simple is the best^^

Altaf Hussain said...

Hi,
I read your tutorial and followed the steps and it worked like a charm. I really appreciate this article

Unknown said...

execute and result easy, i like. thanks very much. By Andreson

FP said...

Can anyone upload the ziped project files, as i am a newbee?

Chikito said...

Thanks for this post, it helped me a lot

Vee Eee Technologies said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.

Unknown said...

It seems that I have problems with step 8, It can't find the webpage. Can somebody please help me?

Nikunj Gandhi said...

Hello robin how your local server is setup.I have setup my local server as http://localhost:8080/ It might be different in your case .

Unknown said...

Ah thank you for your quick answer! And thanks for sharing this great peace of code!

Anonymous said...

I get an error that I can't fix, It's when I try to add the web reference. Could you help me?

Parse error: syntax error, unexpected $end in /home/mcserver/public_html/server/lib/nusoap.php on line 5743

Nikunj Gandhi said...

I think you have to re download library and re-upload to your server.your file might be corrupt.

Thanks.

Anonymous said...

Awesome, It works now !! thanks

Anonymous said...

This is AMAZING dude, THANKS A LOT!

Post a Comment