Creating a New Service Control

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. A Service control is defined in a CTRL file.

This topic discusses the mechanics of creating a Service control.

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

To learn about the Service control, see Service Control: Using Another Web Service.

# Creating a New Service Control

New Service controls are almost always created in order to enable your web service to use an existing web service. The other web service is referred to here as the target web service.

If the target web service was developed with WebLogic Workshop, you may create a Service control directly from the web service's JWS file. No matter how the target web service was developed, you can create a Service control for it if you have a WSDL file for the web service.

To Create a Service Control from a JWS File

If you have a WebLogic Workshop web service (a JWS file) for which you want to create a Service control, so that other WebLogic Workshop web services can use your web service:

1. Ensure that the JWS file for the web service is in your project.

2. Browse to the JWS file in the Project Tree.

3. Right-click on the JWS file in the Project Tree and select the action that generates a CTRL file from a JWS file, as shown here:

The resulting CTRL file is a Service control. It may be used by any other web service in the project, or copied to another project and used by web services there.

Note that WebLogic Workshop will add the word "Control" to the end of the name of generated controls. If you generate a CTRL file from the web service HelloWorld.jws, the CTRL file will be named HelloWorldControl.ctrl.

When you generate a CTRL file from a JWS file in this manner, the CTRL file is automatically linked to its parent JWS file. When you modify the web service, the CTRL file is automatically be regenerated to reflect the change. For example, if you add a method to the web service, an associated CTRL file is automatically regenerated, and the new method is available to every web service that employs that CTRL file as a Service control.

Autogenerated CTRL files in the Project Tree are marked with the icon shown below:

If you modify the source code for an autogenerated CTRL file, when you attempt to save the file WebLogic Workshop warns you that continuing the save operation will turn off autogeneration for this file. If you proceed, the CTRL file will no longer be linked to its parent web service. In general, you probably want to avoid turning off autogeneration for a CTRL file.

Note: When you generate a service control from a JWS file, a method in the JWS file that returns a Java collection, such as a Vector, Hashtable, or ArrayList object, is modified to return an array of type Object.

## Creating a Service Control from a WSDL File

If you have a WSDL file for a web service that you would like to use from your WebLogic Workshop web service:

1. Ensure that the WSDL file for the web service is in your project.

2. Browse to the WSDL file in the Project Tree.

3. Right-click on the WSDL file in the Project Tree and select the action that generates a CTRL file from a WSDL file, as shown here:

The resulting CTRL file is a Service control. It may be used by any web service in the project, or copied to another project and used by web services there.

Note that WebLogic Workshop will add the word "Control" to the end of the name of generated controls. If you generate a CTRL file from the web service HelloWorld.jws, the CTRL file will be named HelloWorldControl.ctrl.

Note: Some web service tools produce WSDL files that do not contain an XML declaration. WebLogic Workshop requires that all XML files contain an XML declaration. The XML declaration is just the first line of an XML file of the following form:

    <?xml version="1.0" encoding="utf-8" ?>

If you receive a WSDL file that does not contain an XML declaration, you must add a declaration to the file using a text editor before you can use the WSDL file in WebLogic Workshop.

Note that the encoding attribute is not required. If an encoding attribute is not present, the default encoding is utf-8.

Note: as of WebLogic Platform 7.0 Service Pack 2, WebLogic Workshop will accept WSDL files that contain more then one service definition. However, a Service control will be generated only for the first service defined in the WSDL file and a warning message will be written to the generated CTRL file.

Related Topics

Customizing a Service Control: Overview

QuoteClient.jws Sample