# Creating a New Http Control

This topic describes how to create a new Http control.

### Creating a New Http Control

You can create a new Http control and add it to your business process. To define a new Http control:

1. Click Add on the Data Palette Controls tab to display a list of controls that represent the resources with which your business process can interact.

Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.

2. Choose Integration Controls to display the list of controls used for integrating applications.

3. Choose Http to display the Insert Control - Http dialog.
4. In Step 1, in the Variable name for this control field, enter the name for your Http control.
5. In Step 2, select the Create a new Http control to use radio button.
6. In the New JCX name field, provide a name for the new file that you are about to create.
7. 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.
8. In Step 3, specify the target URL for your Http control, for example, http://www.bea.com, https://www.verisign.com or http://localhost:7001/console.
9. Select the HTTP mode that you want to use. You can select either the Get, or the Post mode.
10. From the Sending Body Data Type drop-down list, select the data type. You can send your data as an XML object, String, or byte stream. This option is applicable only to the HTTP Post mode.
11. From the Receiving Body Data Type drop-down list, select the data type in which you want to receive data. You can choose to receive data in a different format. For example, if you select the Byte data type for sending data and you want to receive the data as an XML object, you can do it.
12. Click Create. Alternatively, you may create a Http control JCX file manually. For example, you may copy an existing Http control JCX file and modify the copy.

### The JCX file for the Http Control

When you create a new Http control, you create a new JCX file in your project. The following is an example of a JCX file

    package processes;
    import com.bea.control.*;
    import com.bea.wli.control.httpResponse.ResponseDocument;
    import com.bea.wli.control.httpParameter.ParametersDocument;
    import com.bea.xml.XmlObject;
    /*
         * A custom Http control.
         */
         /**
         * @jc:httpsend-data url-name="http://localhost:7001/console"
         */

    public interface GET extends HttpControl, com.bea.control.ControlExtension
         {
         /*
    * A version number for this JCX. This will be incremented in new versions of
    this control to ensure that conversations for instances of earlier versions
    were invalid.
         */
         static final long serialVersionUID = 1L;
    ResponseDocument sendDataAsHttpGet(ParametersDocument parameters,String charset);
    byte[] getResponseBodyData();

The contents of the Http control's JCX file depend on the selections made in the Insert Http dialog. The given example was generated in response to selection of byte[] from the Body Type drop-down list.

### Using the Http Control in a Business Process

The business process starts with a client request node, representing a point in the process at which a client sends a request to a process. In this case, the client invokes the setProperties method on the process to specify a dynamic property for your Http control.

Complete the following tasks to design your business process to send and receive data using your Http control, using a dynamic property setting that specifies the target URL to send and receive data.

- Create an instance of the Http control, and call it MyHttpControl. Use the steps provided in Creating a New Http Control.
- Your new Http control will be visible under the Controls tab in the Data Palette. Expand MyHttpControl to see the Http methods that you can use in your business process.
- Design a Control Send Node in your business process and specify a dynamic property to be used during run time.

To Design a Control Send Node in Your Business Process

1. Expand the MyHttpControl control instance in the Data Palette. Then click the following method:

    setProperties(HttpControlPropertiesDocument propsDoc)

2. Drag the method from the Data Palette and drop it on your business process in the Design View, placing it immediately after the Client Request node.
3. Double-click the SetProperties node. Its node builder opens on the General Settings tab.
4. Confirm that MyHttpControl is displayed in the Control field and that the following method is selected in the Method field:

    setProperties(HttpControlPropertiesDocument propsDoc)

5. Click Send Data to open the second tab in the node builder. The Control Expects field is populated with the data type expected by the setProperties method: HttpControlPropertiesDocument.
6. In the Select variables to assign field, choose Create new variable... using the name dynamicprop. Close the window.
7. Double click on the client request node to open the node builder.
8. Open the General Settings tab of the node builder and create a variable of type com.bea.wli.control.dynamicProperties.HttpControlPropertiesDocument.
9. Open the Receive Data tab. The Client Sends field in this tab populated with the variables that have been created in the General Settings tab, in this case, HttpControlPropertiesDocument x0. In the Select variables to assign field, click the arrow to display the list of variables in your project and choose dynamicprop as the variable to assign.

This step completes the design of your Http control node.

At run time, the dynamic property that you defined will override the static property defined using the Property Editor.