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:
01 <?php
02 // call library
03 require_once ( 'lib/nusoap.php' );
04
05 // create instance
06 $server = new soap_server();
07
08 // initialize WSDL support
09 $server->configureWSDL( 'hellowsdl' , 'urn:hellowsdl' );
10
11 // place schema at namespace with prefix tns
12 $server->wsdl->schemaTargetNamespace = 'urn:hellowsdl';
13
14 // register methode
15 $server->register('hello', // method name
16 array('name'=>'xsd:string'),
17 // input parameter
18 array('return'=>'xsd:string'),// output
19 'urn:hellowsdl' ,// namespace
20 'urn:hellowsdl#hello',// soapaction
21 'rpc',// style
22 'encoded',// use
23 'Say hello to the caller'// documentation
24 );
25
26 // define method as function
27 function hello($name)
28 {
29 return "Hello, ".$name;
30 }
31
32 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
33
34 $server->service($HTTP_RAW_POST_DATA);
35
36 ?>
Ok, now we try to open at VB.NET.
Open your Microsoft Visual Studio 2003.
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.

Right click at Reference in Solution Explorer. Choose add web references.

You will get dialog box.
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:

Put label, textbox, and button. Place like following screen.

Double click botton. Add following code:
1 Dim name As String
2 name = TextBox1.Text
3
4 Dim ws As New localhost.hellowsdl
5 MsgBox(ws.hello(name))
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?
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:
01 <?php
02 // call library
03 require_once ( 'lib/nusoap.php' );
04
05 // create instance
06 $server = new soap_server();
07
08 // initialize WSDL support
09 $server->configureWSDL( 'hellowsdl' , 'urn:hellowsdl' );
10
11 // place schema at namespace with prefix tns
12 $server->wsdl->schemaTargetNamespace = 'urn:hellowsdl';
13
14 // register methode
15 $server->register('hello', // method name
16 array('name'=>'xsd:string'),
17 // input parameter
18 array('return'=>'xsd:string'),// output
19 'urn:hellowsdl' ,// namespace
20 'urn:hellowsdl#hello',// soapaction
21 'rpc',// style
22 'encoded',// use
23 'Say hello to the caller'// documentation
24 );
25
26 // define method as function
27 function hello($name)
28 {
29 return "Hello, ".$name;
30 }
31
32 $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
33
34 $server->service($HTTP_RAW_POST_DATA);
35
36 ?>
Ok, now we try to open at VB.NET.
Open your Microsoft Visual Studio 2003.
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.
Right click at Reference in Solution Explorer. Choose add web references.
You will get dialog box.
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:
Put label, textbox, and button. Place like following screen.
Double click botton. Add following code:
1 Dim name As String
2 name = TextBox1.Text
3
4 Dim ws As New localhost.hellowsdl
5 MsgBox(ws.hello(name))
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?
No comments:
Post a Comment