Service Control: Using Another Web Service

A Service control provides an interface to another web service, allowing your service to invoke the methods and handle the callbacks of the other service. The other web service can be one developed with WebLogic Workshop or any web service for which a WSDL file is available.

As with most controls, a Service control is defined in a CTRL file. A specific Service control CTRL file provides a way to communicate with a specific web service. The name and location of the web service are explicitly stated in the CTRL file.

All Service controls extend the weblogic.jws.control.ServiceControl base class.

To learn about WebLogic Workshop controls, see Controls: Using Resources from a Web Service.

# Understanding Public Contracts

Web services define and expose what is called a public contract. The public contract is typically expressed in a WSDL file.

To learn about WSDL files, see WSDL Files.

The public contract describes the operations that the web service can perform and the format of the messages that should be sent to the service to access the operations and receive operation results. The contract is completely under the control of the author of the web service; it cannot be altered by a client of the web service.

The public contract for a web service developed with WebLogic Workshop is completely defined in the JWS file for the web service: it is the collection of all methods marked with the @jws:operation tag plus all members of the Callback interface. When you generate a WSDL file from a JWS file, the public contract is expressed according to the WSDL standard.

# Service Controls are Proxies for Web Services

In WebLogic Workshop, a Service control serves as an intermediary, or proxy, for a web service. When web service A wants to invoke an operation of web service B, web service A calls a Java method of the Service control for B. The Service control converts the Java method invocation into an appropriate message to send to the web service B, and it communicates with web service B using a protocol that service B says it can understand. The Service control also converts returned messages from B back into Java method invocations on service A, known as callback handlers.

In this way, the Service control allows service A to use service B merely by implementing application-level Java code. As the author of service A, you do not need to know the details of message formats or protocols.

# Using an Existing Service Control

If a Service control CTRL file already exists for another web service that you would like to use from your web service, you only need to add an instance of the Service control to your web service.

Us the Add Service Control Dialog to add a Service control to you web service. The Add Service Control Dialog can be accessed via the Service menu on the Menu Bar; via the right-button context menu on the service in the Design View; or via the Add Control option menu in the upper right corner of Design View.

The image above shows creation of a Service control instance named bank, which is an instance of the Service control defined in the BankControl.ctrl CTRL file.

# Creating a New Service Control

To learn how to create a new Service control, see Creating a New Service Control.

# Customizing Service Controls

There are a limited number of customizations you can make to a Service control's CTRL file to modify the default behavior of the Service control.

To learn about customizing Service controls, see Customizing a Service Control: Overview.

# Service Control Samples

## Samples that Use Service Controls

AdvancedTimer.jws Sample

Conversation.jws Sample

CreditReport.jws Sample

Investigate.jws Sample

## Samples that Customize Service Controls

QuoteClient.jws Sample

Related Topics

WebLogic Workshop Projects

CTRL Files:Implementing Controls

ServiceControl Interface