# Creating a New Web Service Control

A Web Service control makes it easy to access a web service from your application. You create a new Web Service control to access an existing web service. The existing web service is referred to here as the target web service.

You can create a Web Service control for a target web service if that web service publishes a WSDL file. If the target web service was developed with WebLogic Workshop, you can create a Web Service control directly from the web service's JWS file.

## Creating a Web Service Control from a JWS File

This procedure describes how to create a Web Service control if you have a WebLogic Workshop web service (a JWS file) and want other WebLogic Workshop web services to be able 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 Application pane.
3. Right-click on the JWS file in the Application pane and select Generate JCX File.

The resulting JCX file is a Web Service control. Note that WebLogic Workshop adds the word "Control" to the end of the name of generated controls. If you generate a JCX file from the web service HelloWorld.jws, the JCX file is named HelloWorldControl.jcx.

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

If you modify the source code for an autogenerated JCX 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 JCX file will no longer be linked to its parent web service. In general, you probably want to avoid turning off autogeneration for a JCX file.

## Creating a Web Service Control from a Local WSDL File

This procedure describes how to create a Web Service control if you have a WSDL file for the target web service.

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

2. Browse to the WSDL file in the Application pane.

3. Right-click on the WSDL file in the Application pane and select Generate JCX.

## Adding an Existing Web Service Control

You can add a Web Service control in any of the following types of files:

- Java Control (JCS file)
- Java Page Flow (JPF file)
- Java Server Page (JSP file)
- Java Web Service file (JWS file)
- Process file (JPD file)

If a Web Service control already exists for another web service that you would like to use from your application, you only need to add an instance of the Web Service control to your application. To add a Web Service control, follow these steps:

1. Open the file to which you want to add the control in the WebLogic Workshop design environment.
2. Display the Data Palette (View->Windows->Data Palette).
3. On the Data Palette, click the Add drop-down, and choose Web Service. The Insert Control - Insert Web Service dialog opens.
4. In the Variable name for this control field, type the variable name used to access the new Web Service control instance from your application.
5. Choose the Use a Web Service control already defined by a JCX file radio button.
6. If you know the name and filepath of the Web Service control you want to add, enter them in the JCX file field. If you do not know the name and path, click Browse. The Select dialog appears.
7. Navigate to the Web Service control you want to add and click Add.
8. Decide whether you want to make this a control factory and select or clear the Make this a control factory that can create multiple instances at runtime check box. For more information about control factories, see Control Factories: Managing Collections of Controls.
9. Click Create.

You can also create a new Web Service control from the Insert Control - Insert Web Service dialog by indicating that you want to create a new Web Service control and then specifying the location of the WSDL file on which the Web Service control should be based. The WSDL location may be local (within your WebLogic Workshop application) or remote.

Related Topics

Overview: Web Service Controls

QuoteClient.jws Sample