JSP Consumer for a Visual Studio Created Web Service Using Sun Java Studio Creator
(Page 1 of 6 )
It isn't supposed to matter to a web service what platform or programming language it's dealing with. When Sun Java Studio Creator first appeared in beta two years ago, it apparently was not fully compatible with Visual Studio. Now that both languages have changed, it is possible to create a JSP web client in one of them for a simple web service created in the other. This article explains how.
Introduction
Web services are supposed to be platform and programming language agnostic in nature. This is of utmost importance to any and every kind of business operation throughout the Internet. In 2004 when the Sun Java Studio Creator surfaced in its beta, I tried to create a JSP web client to access a web service created with Visual Studio 2003. I did not succeed and rationalized in a way that was not satisfactory.
This tutorial is about revisiting that scene. Both of the software programs have changed and much water has flowed under the bridge. This tutorial will show how to create a JSP web client using Sun Java Studio Creator for a simple web service created with Visual Studio 2005. Both of these programs as well as the IIS 5.1 web server are running on the same computer using the Windows XP Professional Media Center Edition operating system.
Creating the Web Service
Create a new website project with Visual Studio 2005 from the File-->New website drop-down. This opens up the New Web Site window. From the Visual Studio Installed Templates area select the ASP.NET Web Service. You have to give a name to the web site; it's called Jikan in this tutorial.

When you click on the button labeled OK in the above window you will have created the Jikan web site with a folder/file structure as shown.

The files Service.asmx and Service.vb are the main files for the web service that will be created. Although it is advisable to change the name of the files to something different from this default naming, the defaults were taken in this tutorial as is. The content of the Service.asmx file is quite simple as shown here.
<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %>
The Service.vb file comes with a default example of a web method described by the function Helloworld(). This has been retained and a second method called Curtime() has been added whose purpose is to get the current time on the server. The variable y will have the server time information. The next paragraph shows the Service.vb file
Service.vb
Imports System.Web
Imports Service
Imports System.Web.Services
Imports System.Web.Services.Protocols
<="http: designtimesp="18399"> _
<=wsiprofiles.basicprofile1_1)(> _
_
Public Class Service
Inherits System.Web.Services.WebService
_
Public Function HelloWorld() As String
Return "Hello World"
End Function
<="get designtimesp="18403"> _
Public Function Curtime() As String
Dim x As System.DateTime
x = System.DateTime.Now
Dim y As String = x.Date
Return y
End Function
End Class
Next: Test the Web Service In-situ >>
More Java Articles
More By Jayaram Krishnaswamy