Web Service Example
Any application can have a Web Service component.
Web Services can be created regardless of programming language.
An example ASP.NET Web Service
In this example we use ASP.NET to create a simple Web Service.
<%@ WebService Language="VBScript" Class="TempConvert" %>
Imports System
Imports System.Web.Services
Public Class TempConvert :Inherits WebService
<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
return ((((fahr) - 32) / 9) * 5)
end function
<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
dim cel
cel=trim(replace(Celsius,",","."))
if cel="" or IsNumeric(cel)=false then return "Error"
return ((((cel) * 9) / 5) + 32)
end function
end class
|
This document is a .asmx file. This is the ASP.NET file extension for XML Web
Services.
To run this example you will need a .NET server.
The first line in this document that it is a Web Service, written in VBScript and the
class name is "TempConvert":
<%@ WebService Language="VBScript" Class="TempConvert" %>
|
The next lines imports the namespace "System.Web.Services" from the .NET
framework.
Imports System
Imports System.Web.Services
|
The next line defines that the "TempConvert" class is a WebService
class type:
Public Class TempConvert :Inherits WebService
|
The next step is basic VB programming. This application has two functions.
One to convert from Fahrenheit to Celsius, and one to convert from Celsius to
Fahrenheit.
The only difference from a normal
application is that this function is defined as a "WebMethod".
Use "WebMethod"
to mark the functions in your application that you would like to make into web
services.
<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
return ((((fahr) - 32) / 9) * 5)
end function
<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
dim cel
cel=trim(replace(Celsius,",","."))
if cel="" or IsNumeric(cel)=false then return "Error"
return ((((cel) * 9) / 5) + 32)
end function
|
The last thing to do is to end the class:
If you save this as an .asmx file and publish it on a server with .NET
support, you should have your first working Web Service. Like our
example Web Service
ASP.NET automates the process
With ASP.NET you do not have to write your own WSDL and SOAP documents.
If you look closer on our example Web Service. You will see that the ASP.NET
has automatically created a
WSDL and
SOAP
request.
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |

|
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |

|
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Promote collaboration among coworkers in your organization through project workspaces where others can efficiently find information and work together |

|
Personalize your company profile by bookmarking and organizing favorite content, uploading assets, posting photos, blogging, and more |

|
Interact with features like tagging, flagging, wikis and ratings found in the Web 2.0 Toolbox |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide. Request an
INSTANT DEMO or download a
FREE TRIAL today. |
|