Implementing Web Services with EAServer

Web Services Overview

Simply put, Web Services offers a means by which application components can be made accessible to other applications using open protocols. The tools of the Web Services revolution include Simple Object Access Protocol (SOAP), Web Services Description Language (WSDL), and Universal Description, Discovery and Integration (UDDI). Using these protocols and standards, a Web Service contained in EAServer can be invoked remotely over HTTP and HTTPS protocols. Likewise, the PowerBuilder developer can invoke third-party components from application providers anywhere in the world.

The Web Services object has methods or end points that provide the business logic of the Web Services being invoked. Methods are called using SOAP and the client calling these methods is said to "consume" the Web Services. WSDL describes the service and can be used in client applications. You can also publish business and service information to a UDDI registry site on the Web and make your Web Services available to other users. SOAP provides a platform and language-neutral way to access these services. Using SOAP, WSDL, and UDDI, collaboration between business partners is easier because interfaces between applications become standardized across platforms.

The purpose of this article is to explain how to expose PowerBuilder components running on EAServer 5 as Web Services. Depending on the version of PowerBuilder, the method of exposing a component as a Web Service will vary so this article takes you step-by-step through the two approaches. Once we've exposed our component, we'll create a .NET client to invoke the Web Service and demonstrate the transparency of cross platform communication using Web Services.


EAServer and Web Services

Web Services are embedded in Sybase's Web container environment. This environment supports the following standards: SOAP 1.1, WSDL 1.1, JAX-RPC 1.0, JAXM 1.0, JAXP 1.1, UDDI 2.0. Sybase provides a Web Services Toolkit (WST) in EAServer 5 to make Web Services development easy and quick. WST is part of the default installation in EAServer 5 and supports the following styles:


RPC - the body of the SOAP message is an RPC call containing the method name and serialized versions of the parameters. RPC services use the SOAP RPC conventions, and also encoding rules defined in section five of the SOAP specification.

Document -the body of the SOAP message is viewed as an XML document, as opposed to an RPC call. Document services do not use any encoding, but still provide XML-to-Java databindings.

Wrapped - similar to document services, except that rather than binding the entire SOAP body into one big structure, they "unwrap" the body into individual parameters.

The WSDL file for a deployed Web Service can be retrieved easily from a Web browser by entering the URL of the WSDL in the form:
http://host:port/collectionName/services/service?wsdl.

The Eclipse Plug-In

If you're developing on a version of PowerBuilder older than PB 10, you'll expose your Web Services components using the Eclipse plug-in to EAServer 5. PowerBuilder 10 was designed with Web Services in mind so no plug-in is required. Eclipse is a full-featured, open source software development platform that provides developers and administrators the ability to manage Web Services contained in EAServer. Taken together, Eclipse and the Sybase Web Services plug-in are referred to as the Web Services Toolkit development tool (WST development tool) in Sybase documentation. The WST development tool provides graphical administration facilities for Web Services, including support for development, deployment, and runtime monitoring of Web Services-related statistics and messages. You can develop Web Services and create test clients for third-party Web Services. Just remember that you must be connected to a running server in order to deploy Web Services to the runtime engine (EAServer, for example) and create test clients for Web Services deployed to EAServer.

Creating a Web Service Component

Now let's look at the different steps involved in developing and exposing a PowerBuilder component in EAServer using PowerBuilder 9.

Start by creating a basic component using the PowerBuilder IDE:
From Menu select File > New.
Select the Workspace tab from Window and click.
Input Workspace name and input path and click.
In order to create a new target select File > New.
Select the Target tab page from the Window and click on "OK" "EAServer Component" option.
This will start a wizard. Follow the different steps of the Wizard and create new EAServer component. In this case, a component named n_hello with package name HelloWorld was created.

Note: Make sure to select the Auto demarcation/Deactivation property since only stateless components can be exposed as Web Services.

Add a simple function of_hello to this component as shown below.

Finally, deploy the component to EAServer.

Once we get our component in EAServer, the next step is to expose the component as a Web Service. This is a simple process accomplished as follows:

Start Eclipse by running starteclipse.bat file from \Program Files\Sybase\Shared\eclipse.
Connect to EAServer.

Expand the "Other Components" node from the tree. Here we
Expand the HelloWorld node from the tree to see the n_hello component in treeview.
Right click on the n_hello component and select the "Expose as Web Services" option from the pop-up menu.

Follow the wizard in order to expose the component as a Web Service.

After finishing the process, I can view the WSDL in a browser at the following URL:

http://sani:8180/ws/services/n_hello?wsdl

Calling the Web Service

Once we have our component exposed as a Web Service, we are ready to call it from a client. In this example, I will create a C# .NET client as follows:
Start VisualStudio and create a new C# Windows application project.
From the Solution Explorer, right click on "References" and select "Add Web Reference" from the pop-up menu.
For the URL, enter the location of your WSDL and click on the "Go" button.
It will search that Web Service and enable the "Add reference" button. Add a reference to this Web Service by selecting this button.

After adding this Web Service to your project, you will see this Web Service in Solution Explorer as a "Web References" tree view item.

Now you can call this Web Service easily with the help of the following code:

your_host_name.n_hello webService = new your_host_name1.n_hello();
MessageBox.Show(webService.of_hello( ) );

Creating a Web Service Component Using PowerBuilder 10

I will end by demonstrating how to create Web Services using the PowerBuilder10 IDE. In PowerBuilder10, a check box has been added to the EAServer Component wizard that lets you choose to make an EAServer component available as a Web Service. You simply set the Web application, service name, and port you want to use for the Web Service.

You can also set these properties on the Web Services page of the EAServer Component properties dialog box in the Project painter.

The following table is a detail of different properties available on the "WebService" tab.

After setting these properties, deploy and expose Web Service components in the same way you deploy EAServer components.

Contact Us


PowerObjects Logo

718 Washington Ave. N.
Suite 202
Minneapolis, MN 55401
612.339.3355
1.866.770.3355
info@powerobjects.com

Passion

"Leverage technology to solve business problems."


Core Values

  • Always Add Value
  • Think Team
  • Love What You Do
  • Live the Technology
  • Do the Right Thing

Exchange Hosting

PowerObjects is now offering full service MS Exchange hosting at $9.95 per 500 MB mailbox!

Contact sales@powerobjects.com

» learn more