Creating an Oracle Web Service Client for a Web Service Created in VS 2005

This tutorial takes you through the process of creating a web service client using the ApplicationBuilder interface in Oracle 10g XE. The client will access the services offered by a web service created using the Visual Studio 2005.

Introduction

This is a continuation of my series of web service related articles exploring interoperability, albeit in simple cases. Oracle XE’s ApplicationBuilder is based on Oracle’s most used Application Express, which was formerly called HTML Db.

Creating the Web Service in Visual Studio 2005

It is very easy to create a web service using Visual Studio, especially for this simple, basic example. In fact the default web service, HelloWorld, is used.

Create a web site from File –>New Website. This opens up the New Web Site window where you choose an ASP.NET Web Service. The URL should be pointing to the localhost. Change the default site name from WebSite to something suitable. In this case the site name is TestingService as shown in the next picture.

The program adds a Service1.asmx file which has been changed to HelloOra.asmx. The Service Class file appears as follows:

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
     Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Web Service Created to test an Oracle Client"""
    End Function

End Class

The Solution Explorer will be as shown in the next picture. The asmx file is the web service file.

The Return value has been changed to “Web Service Created to test an oracle client” above. You may build this, and by browsing the HelloOra.asmx file it can be seen that the service is functional as seen in the next picture.

Displaying the Soap-Endpoint

The service may be invoked by clicking the hyperlink, HelloWorld and the success of the HTTP-post is seen in the next display when you invoke the service.

The WSDL Web Reference

In the earlier screen if you were to click on the hyperlink for Service Description you would see the WSDL file, which contains the complete description of the service. A node compressed view of the displayed wsdl file is shown in the next picture.

The URL of the WSDL is going to be used while configuring the Oracle client application. This url is:

 http://localhost/TestingService/HelloOra.asmx?WSDL

{mospagebreak title=Creating the Client Application in Oracle 10G XE}

Introduction

Oracle 10G XE has an ApplicationBuilder Interface which can be used to create a client application that will access the service created and described earlier. You need to create a web service reference. You will be using a wizard to accomplish this task. The wizard will examine the web service reference either from a UDDI registry that you will point to by browsing the available ones, or the WSDL URL reference you will provide. This was the reason we made a note of the WSDL’s URL reference. The ApplicationBuilder also allows you to create a form based on a blank web page which may be posted to the web service.

Creating an Application

Log on to the HR database using username: hr, password: hr by accessing the URL from the short cut, Go To Database Home Page. You may have to review an earlier article which describes how you may log in as SYSTEM and give permission to the hr database.

Click on the down arrow of the Application builder to choose “Create Application” as shown.

Give a name to the application, in this case GetNetSvc as shown. Keep the other defaults, and click on the button Next. From here on, you will go through several steps till you reach the “Confirm” stage as you can see on the left of this page. The applications are serially numbered, this being 103.

 

 

In this section you will add different items such as a blank page, form, report and so forth. These are all empty, to start with some basic functional items. The default page has been changed to OracleClient. Click on AddPage; this takes you to the next screen. This screen shows the page you added as well as the source of data, if it depends on data. In this case there is no data (this is in case the page is for a form or a report). You may add another page, if you like, or click on Next.

This takes you to the “tab” stage of the CreateApplication wizard. You choose “No Tabs” since we do not require any, as shown. Click on the Next button.

 

The shared component choice has to be made as shown in this picture. The web service happens to be a shared component; choose the “Yes” button and click on the Next button.

For application attributes we choose no authentication as shown for Authentication Scheme, and accept the other defaults. Click on the Next button.

For the UI, we choose the default, Theme 1. Click on the Next button.

 

In the confirm stage keep the check mark, Save this definition as a design model a design for reuse. Later on, we will recall this model and make changes.  Click on the button Create

This takes you to the application creation success page and the breadcrumb changes to Application103 as shown.

{mospagebreak title=Creating a Web Reference}

Now click on the down arrow of the SharedComponents icon. From the drop down choose Logic–>Web Service References as shown and click.

This takes you to creating the reference. Click on Create a reference. Watch the ‘breadcrumb!

You have two choices in creating the reference as shown in this picture. You can either create it from the UDDI registry, or your own URL reference. Since you will be using your own reference choose that option (No) and click on the Next button.

Note that the wizard skips the tModel which would be accessed had you chosen the UDDI. Now you are asked to fill in the URL of the WSDL file. Browse to that page on the web browser and copy the URL, or if you have noted down the URL you can just type it in as shown.

If you click the up button it will take you to only two of its sites, as shown in a different window. We will close this as we will not be using either of these. Just enter the URL in the previous screen as shown and click next.

This will take some time as the program has to access the service and analyze  the WSDL file to make sure everything is okay. This will then lead to the next screen which shows the web service reference’s details: the name of the service,  and the input and output from the service. Remember that the service we created has no input, but returns an output. The asmx file we created is correctly recognized as the soap-endpoint.

Create Reference button when clicked will create the reference and let you know it has been successfully created. You can view the web service reference which will just show your URL. You can also create a form or a report. The form when submitted will call up the service. Click on the icon Create Form on Web Service.

{mospagebreak title=Creating a Client Form}

In this ‘breadcrumb,Create Form on Web Service, you choose the service and you choose the operation. “Service” corresponds to the service created in Vb.Net (in this case) and the operation corresponds to the web method in the service. There could be multiple web methods. In this case there is only one, HelloWorld as shown. Click on the button Next

Using the Reusable Page

In this screen you need to choose the page. Since we already created a page we click on the up arrow by the side of default Page2, which opens up a new window where there are two choices, the 101Login and the page we created earlier, OracleClient (not to be confused with the OracleClient program). Choose OracleClient and click. This will make Page1 replace Page2.

 

The next page is for input, if any. Since for this service there is no input (this screen shot is not shown), click Next.

This is the output parameter stage of the page creation. Clicking on the button Next will take you to the “tabs” stage of the page creation wizard, but since there were no tabs in this page, the wizard wisely skips this and goes to the “Confirm” stage as shown.

Now click on the button CreateForm to create the form. We could have also started with a form in the first place. This brings you to the successful end of creating the form. You can run the form, or edit the form by choosing to click on either of these icons. Let’s try “run” by clicking on it.

{mospagebreak title=Displaying results from Web Service}

When you click on the icon “Run Page” you will see the form as shown in the next picture. This is the template you chose to work with. The form creation added the “Submit” button and the other controls to this blank page, and wired them up for network access.

When you Click on the “Submit” button, the form gets submitted to the web service and the result from the service gets entered into the HelloWorldresult textbox as shown. Looks like there is more work to do to increase the size of the textbox! But that will be for another session.

Summary

It is relatively easy to create a web service client from the Oracle10g XE IDE. The UI is very attractive and extremely flexible. It supports the choice of creating reusable web pages of various forms so that several steps can be skipped depending on the model chosen, which should help with much more rapid development. One of the differences that may be noted while using this IDE is the lack of support for browsing the internal (local web server) WSDL resources. Visual Studio 2005 has a better interface in this regard. In Oracle 10g XE you have either the UDDI or the other two public APIs.

[gp-comments width="770" linklove="off" ]

antalya escort bayan antalya escort bayan Antalya escort diyarbakir escort