phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Services: How PHP Kiss VB.NET? (Part 2)

Tag: web services, NuSoap, VB.NET   Category:
post: 16 Nov 2007 read: 1,544


After build server function (web services). Now we try to read the web service from VB.NET. It will give idea how to we develop multiplatform application.

For this tutorial, I use Microsoft Visual Studio 2003. For this tool, it can accept web services standar using WSDL (Web Services Describe Language). So we must create wsdl before.

Create "server_wsdl.php" within test/nusoap. Enter following code:


 <?php
 // call library
 require_once ( 'lib/nusoap.php' );
 
 // create instance
 $server = new soap_server();
 
 // initialize WSDL support
 $server->configureWSDL( 'hellowsdl' , 'urn:hellowsdl' );
 
 // place schema at namespace with prefix tns
 $server->wsdl->schemaTargetNamespace = 'urn:hellowsdl';
 
 // register methode
 $server->register('hello', // method name
   array('name'=>'xsd:string'),
// input parameter
   array('return'=>'xsd:string'),// output
   'urn:hellowsdl' ,// namespace
   'urn:hellowsdl#hello',// soapaction
   'rpc',// style
   'encoded',// use
   'Say hello to the caller'// documentation
 );
 
 // define method as function
 function hello($name)
 {
 	return "Hello, ".$name;
 }
 
 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
 
 $server->service($HTTP_RAW_POST_DATA);
 
 ?>

Ok, now we try to open at VB.NET.

  1. Open your Microsoft Visual Studio 2003.
  2. File > New > Project. You will get dialog box. Choose visual basic projects at Project Types and Windows Application at Templates. Choose name and location where your application saved. Click OK button.
  3. Right click at Reference in Solution Explorer. Choose add web references.

    You will get dialog box.

  4. Put http://localhost:8048/test/nusoap/server_wsdl.php?wsdl at URL. You should get like this:

    Click Add Reference button. Your Solution explorer should like this:

  5. Put label, textbox, and button. Place like following screen.
  6. Double click botton. Add following code:
    
      Dim name As String
      name = TextBox1.Text
    
      Dim ws As New localhost.hellowsdl
      MsgBox(ws.hello(name))
    
  7. Press F5 for run.

Put a name at textbox, then click button. You will get message box like following screen:

It is simple, isn't it?



Series this article:
Web Services: How PHP Kiss VB.NET? (Part 1)
Web Services: How PHP Kiss VB.NET? (Part 2)
PHP - Web Services: Serving Data Array
PHP - Web Services: Fetching Data From Database

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting