![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Note: | The Http control is available in BEA Workshop for WebLogic Platform only for licensed users of WebLogic Integration. |
Hyper-Text Transfer Protocol (HTTP) is the globally-accepted method of communicating web pages across the internet. It is a stateless, application-level protocol. The currently defined version of HTTP is 1.1. HTTP protocol is a synchronous protocol, that is, each request message sent from the client to a server is followed by a response message returned from the server to the client.
The Http control's purpose is to provide outgoing HTTP access to BEA Workshop for WebLogic Platform clients. The Http control complements the other controls provided in WebLogic Integration and can be used with BEA Workshop for WebLogic Platform and business processes to work with HTTP requests and process responses. The Http control is built using the features of the WebLogic Platform control architecture. The Http control source file is a wrapper around the Jakarta Commons HttpClient package. The Http control conforms to HTTP/1.1 specific features.
The Http control supports two types of request methods for data transfer, namely Get and Post. By using the Get mode, you can send your business data along with the URL. By using Post mode, you can send large amount of information like Binary, XML and String documents to the server within the body of the request.
You can specify Http control properties in an annotation, or pass dynamic properties via an XML variable. Inbound HTTP requests can be processed with the HTTP event generator. The HTTP event generator is a servlet which takes an HTTP request, checks for the content type and then publishes the message to the message broker. For more information on the HTTP event generator, see The HTTP Event Generator.
Using the Http control, you can send an HTTP or HTTPS (Secure HTTP) request to a URL and receive specific HTTP response header and body data, as follows:
This topic describes how to create a new Http control.
You can create a new Http control and add it to your business process. To define a new Http control:
Note: | If the Data Palette view is not visible in BEA Workshop for WebLogic Platform, click Window![]() ![]() |
The Insert control: Http dialog box appears
http://www.bea.com
, https://www.verisign.com
or http://localhost:7001/console
.When you create a new Http control, you create a new java control file in your project. The following is an example of a java control file
package requestquote;
import org.apache.beehive.controls.api.bean.ControlExtension;
import com.bea.wli.control.httpParameter.ParametersDocument;
import com.bea.wli.control.httpResponse.ResponseDocument;
/*
* A custom Http control.
*/
@ControlExtension
@com.bea.control.HttpControl.EndPoint(url = "http://www.bea.com")
public interface HttpControl extends com.bea.control.HttpControl {
@MethodType(method = METHOD.GET)
public ResponseDocument get(ParametersDocument parameters, String charset);
@MethodType(method = METHOD.GETRESPONSE)
public byte[] getResponseData();
static final long serialVersionUID = 1L;
public HttpControl create();
}
The contents of the Http control's java 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.
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.
setProperties(HttpControlPropertiesDocument propsDoc)
setProperties(HttpControlPropertiesDocument propsDoc)
setProperties
method: HttpControlPropertiesDocument.
dynamicprop
. Close the window.com.bea.wli.control.dynamicProperties.HttpControlPropertiesDocument
.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.
Most aspects of a Http control can be configured from the Properties pane in Design View. You can also specify run-time properties that define the way your Http control is used during run time. For more information on how to use run time, or dynamic properties, see Setting Dynamic Http Control Properties.
You can define the control properties in the Properties pane, or, you can change the properties in the Source view of the Http control's java file. For more information on the java file for the Http control, see The Java file for the Http Control.
When you modify properties for your Http control using the Properties pane, your changes are reflected in the Source view of the control's java file, and vice versa. However, the properties that you specify during run time override the properties set using the Property Editor in the Design view. For more information on setting properties, see Using HTTP Methods to Set Properties.
You can specify the behavior of an Http control in Design View by setting the control's properties in the Properties pane. The following attributes specify class- and method-level configuration attributes for the Http control.
This topic defines the various HTTP methods that you can use to specify properties. Each method is described briefly in Http Control MethodsTable 8-1, and detailed in subsequent sections that are referenced to the methods outlined in the table.
You can use the following methods with the Http control:
Method: void setProperties(HttpControlPropertiesDocument propsDoc)
To use dynamic properties, pass an XML variable that conforms to the Http control's dynamic-property schema to the Http control's setProperties() method.
<?xml version="1.0" encoding="UTF-8"?>
<xyz:HttpControlProperties xmlns:xyz="http://www.bea.com/wli/control/dynamicProperties">
<xyz:URLName>http://localhost:7001/console</xyz:URLName>
</xyz:HttpControlProperties>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.bea.com/wli/control/dynamicProperties" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.bea.com/wli/control/dynamicProperties" elementFormDefault="qualified">
<xs:element name="HttpControlProperties">
<xs:complexType>
<xs:sequence>
<xs:element name="URLName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Method: setConnectionTimeOut (int timeoutInMilliSeconds)
This method sets the connection time out for an HTTP request. The connection time-out is maximum time that a control is allowed to establish a connection - the connection fails after this time elapses. The parameter time-out is set in milliseconds. A time-out value of zero (zero is the default value) indicates that the connection time-out has not been used.
Method: setConnectionRetrycount (int retryCount)
This method sets the retry count, that is, the number of times your application will retry for the HTTP request. If this value is not specified, then the application will try to connect only once. If a connection is not established in the first try, the second attempt is likely to succeed. It is recommended that you set this property so that your HTTP requests go through in the second attempt, if not the first one.
Method: setServerSideSSL (String trustStoreLocation, boolean hostVerificationFlag)
The Http control provides complete support for HTTP over Secure Sockets Layer (SSL) and Transport Layer Security (TLS), by leveraging the Java Secure Socket Extension (JSSE). JSSE is integrated into JDK1.4, which is shipped along with WebLogic Integration Platform.
When you run this method, the configuration for server-side authentication is set. By default, JSSE uses (jdk142_04\jre\lib\security\cacerts
) as its Trust Store location, which includes some well-known certificate authorities such as Verisign and CyberTrust. Therefore, you do not need to specify any Trust Store locations for the certificates, which are issued by the certification authority.
Additionally, you can provide a host-name verification flag that ensures that the SSL session's server host-name matches with the host name returned in the server certificates Common Name field of the SubjectDN entry. By default this entry is set to False
.
For example, if you specify https://www.verisign.com/
as the URL for authentication, you do not have to specify the Trust Store location, as Verisign is a trusted authority in certificates of JSSE.
To accept self-signed or SSL certificates that are not trusted, you need to import the server certificates into its Trust Store Location. For more information on JSSE, see the Java Secure Socket Extension (JSSE) Reference Guide at the following location:
http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html
The following example shows how to create a store, import a server certificate, and to specify the parameters for this method:
keytool -genkey -alias
aliasname
-keyalg rsa -keystore
keystore name
The following is an example of the command, including user-input values:
keytool -genkey -alias teststore -keyalg rsa -keystore c:\teststore.jks
For more information, see Creating a Keystore to Use with JSSE, at the following location:
http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html
https://
host
:
port
/console
format. When you are prompted for the server certificate, click the View Certificate button, navigate to the Details tab, and then click Copy to File.
keytool -import -alias aliascertname
-file certificatename
-keystore keystore_name
keytool -import -alias testcer -file c:\test.cer -keystore c:\teststore.jks
setServerSideSSL
method, specify the Trust Store location as C:\
teststore
.jks
and the URL to which you send a request as https://
host
:
port
/console
. To verify the host name, set the host-name
verification flag as true
.
Method: setClientSideSSL (String keyStoreType, String keyStoreLocation, String keyStorePassword, String keyPassword)
This method sets the configuration for client-side authentication. You should use this method when both server-side and client-side authentication are required. Before configuring this method, you must configure Configuring Server-side SSL.
In this method, both the keyStoreType
and keyPassword
fields are optional. If you do not specify the keyStoreType, the method uses the default Keystore type (which is specified in the java.security
file).
For some Keystores, the Keystore password differs from the key password. In such cases, you must specify both the Keystore password and key password.
If you want both server-side and client-side configuration, the server certificate should be in the Client Trust Store. Similarly, the client certificate should be in the Server Trust Store and the client should specify the Keystore location and passwords appropriately.
Method: setProxyConfig (String host, int port, String userName, String password)
This method configures parameters for a proxy server. To send an HTTP request using a proxy server, you must properly configure the host, port, user name, and password.
Note: | The Http control supports the Basic Scheme protocol. It does not support NTLM protocol. You need to configure your proxy settings accordingly. |
Method: setCookies(CookiesDocument cookies)
The Http control allows you to manually set the cookies sent to the server. To send cookies to the server with an HTTP request, you have to pass a XML variable that conforms to the Http control's cookies document schema.
<?xml version="1.0" encoding="UTF-8"?>
<Cookies xmlns="http://www.bea.com/wli/control/HttpCookies">
<Cookie>
<Name>CookieName1</Name>
<Value>CookieValue1</Value>
</Cookie>
<Cookie>
<Name>CookieName2</Name>
<Value>CookieValue2</Value>
</Cookie>
</Cookies>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.bea.com/wli/control/HttpCookies" elementFormDefault="qualified" targetNamespace="http://www.bea.com/wli/control/HttpCookies">
<xs:element name="Cookies">
<xs:complexType>
<xs:sequence>
<xs:element name="Cookie" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"
minOccurs="0"/>
<xs:element name="Value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Method: setHeadersForHttpPost (HeadersDocument headers)
This method sets the request header for an HTTP Post. To set the request header, you have to pass an XML variable that conforms to the Http control's headers document schema. You can overwrite the default header's values by specifying them in the following manner:
User-agent
, Content-Type
, and so on.
<?xml version="1.0" encoding="UTF-8"?>
<xyz:Headers xmlns:xyz="http://www.bea.com/wli/control/HttpHeaders">
<xyz:Header>
<xyz:name>Content-Type</xyz:name>
<xyz:value>text/*</xyz:value>
</xyz:Header>
<xyz:Header>
<xyz:name>header</xyz:name>
<xyz:value>h1</xyz:value>
</xyz:Header>
</xyz:Headers>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.bea.com/wli/control/HttpHeaders" elementFormDefault="qualified" targetNamespace="http://www.bea.com/wli/control/HttpHeaders">
<xs:element name="Headers">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Method: ResponseDocument sendDataAsHttpGet(ParametersDocument parameters,String charset)
Use this method when you want to send an HTTP Get request. The Get request is mostly used for accessing static resources such as HTML documents from a Web Server and also can be used to retrieve dynamic information by using additional parameters in the request URL.
With Get requests, the request parameters are transmitted as a query string appended to the request URL. To include multi-byte character parameters in the URL, the Http control encodes the parameters to the characters as defined by the charset
field of this method. If you do not specify any character set, then the Http control will send the parameter data URL encoded in "UTF-8". To send the parameters with a URL, you must pass the parameters in an XML variable that conforms to the Http control's parameter document schema.
<?xml version="1.0" encoding="UTF-8"?>
<xyz:Parameters xmlns:xyz="http://www.bea.com/wli/control/HttpParameter"> <xyz:Parameter>
<xyz:Name>Customer Id</xyz:Name>
<xyz:Value>1000</xyz:Value>
</xyz:Parameter>
<xyz:Parameter>
<xyz:Name>Customer Name</xyz:Name>
<xyz:Value>Robert</xyz:Value>
</xyz:Parameter>
</xyz:Parameters>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.bea.com/wli/control/HttpParameter" elementFormDefault="qualified" targetNamespace="http://www.bea.com/wli/control/HttpParameter">
<xs:element name="Parameters">
<xs:complexType>
<xs:sequence>
<xs:element name="Parameter" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"
minOccurs="0"/>
<xs:element name="Value" type="xs:string"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Method: ResponseDocument sendDataAsHttpPost (String/XmlObject/byte[ ] bodyData)
Use the HTTP Post method to post data to a server. The Http control allows you to post data of three different data types: String, XmlObject, and byte.
The HTTP Post method returns the HTTP response, that is, the HTTP response code and corresponding message in a ResponseDocument. The schema of the response document is the same as described in Schema for Sending Parameters for HTTP Get.
HTTP Post requests are meant to transmit information that is request-dependent, and are used when you need to send large amounts of information to the server. The Http control allows you to post data of three different data types: String, XmlObject, and Byte stream.
In the HTTP protocol, servers and clients use MIME (Multipurpose Internet Mail Extensions) headers to indicate the type of content present in requests and responses. Http control also uses the MIME header(Content-Type), while transmitting data in body of the requests, to describe the type of data being sent. So while posting String or XmlObject data type, you should set the Content-Type
header appropriately by using the Http control's setHeadersForHttpPost()
method. The Content-Type
header contains a charset
attribute that indicates the character set of the message body.
If you do not set any charset
attribute, then the Http control uses the default HTTP encoding (ISO-8859-1) to encode the message.
The following examples provide more information on how to send data using the HTTP Post mode:
To post a string message of encoding Shift-JIS
, you should set the charset
attribute in the Content-Type request header, by calling the Http control's setHeadersForHttpPost
method, as follows:
Content-type="text/*; charset=Shift-JIS"
While sending request messages of XML data type, you have to set the charset
attribute in Content-Type
header appropriately.
If you do not specify the character encoding in the Content-Type
header, then the Http control uses the default encoding as specified in rfc3023
.
For example, to post an XML document of encoding EUC-JP
, you need to set the request type header as follows:
Content-Type="text/xml; charset=EUC-JP"
If you do not specify any charset
attribute in the request header, the Http control uses us-ascii
as default encoding to encode the message.
Note: | To avoid garbling of body data while posting String or Xml data types, you should always specify the charset attribute in the Content-Type header. |
The HTTP Post method returns the HTTP response, that is, the HTTP response code and corresponding message in a ResponseDocument. The schema of the response document is the same as described in Schema for Sending Parameters for HTTP Get.
Method: HeadersDocument getResponseHeaders
Use this method to receive the HTTP response headers. The response headers are returned in an XML variable of a pre-defined schema.
The schema for the response headers is same as request headers schema described in Setting Headers for HTTP Post.
Method: CookiesDocument getCookies
Use this method to receive the cookies from the server. The cookies are returned in an XML document of a pre-defined schema.
The schema for the response cookies is same as the request cookies schema described in Schema for Setting Cookie.
Method: String getResponseBodyAsString / XmlObject getResponseBodyAsXml / byte[ ] getResponseBodyAsBytes
In HTTP, in response to a HTTP request, the server sends the body content that corresponds to the resource specified in the request. If you want to receive the response body data, then you should use this method.
The Http control can return the response data in three different data types: String, XmlObject, and Byte[]. You should set the response data type appropriately, depending upon the response data that you expect from the server. If the response body is not available or cannot be read, the control returns a null value.
Note: | While parsing the response body of data type String or XmlObject, the Http control uses the character encoding specified in the Content-Type response header. If character encoding is not specified in the Content-Type header, the Http control uses the default HTTP content encoding ISO-8859-1 for String and US-ASCII encoding for XmlObject . |
Note: | To avoid garbling of data, you should always set the charset attribute in the Content-Type response header. |
During run time, the Http control checks for different parameters, null value, and method return types. If validation fails at any point, a control exception is thrown to the Business Process Management (BPM). You can log debug messages, review them, and resolve exceptions if required.
To log debug messages, edit the WebLogic Workshop log properties file. You can find the workshop log properties file, workshopLogCfg.xml
, in the WL_HOME
\weblogic81\common\lib\
folder.
To log all the debug statements for HttpControlImpl
and HttpResource
class files, add the following lines to the workshopLogCfg.xml
file:
<category name="com.bea.control.HttpControl">
<!-- NOTE: DO NOT CHANGE THIS PRIORITY LEVEL W/O WLI DEV APPROVAL -->
<!-- Debug-level log information is frequently the only tool available to
diagnose failures! -->
<priority value="debug"/>
<appender-ref ref="SYSLOGFILE"/>
<appender-ref ref="SYSERRORLOGFILE"/>
</category>
<category name="com.bea.control.HttpResource">
<!-- NOTE: DO NOT CHANGE THIS PRIORITY LEVEL W/O WLI DEV APPROVAL -->
<!-- Debug-level log information is frequently the only tool available to
diagnose failures! -->
<priority value="debug"/>
<appender-ref ref="SYSLOGFILE"/>
<appender-ref ref="SYSERRORLOGFILE" />
</category>
All debug statements are logged into workshop_debug.log
file in the corresponding domain where the application runs.
The following are the known limitations of the Http control:
sendDataAsHttpPost(byte[] bodyData)
method to post data.The HTTP event generator is a servlet that takes an HTTP request, checks for the content type in the HTTP request, and then appropriately publishes the message to the Message Broker.
The HTTP event generator supports two message data types (XML and binary). The data-type is determined from the Content-Type header of the HTTP request, property name, and matching values, as well as other handling criteria are specified in the channel rules of the event generator.
You need to configure event generator channels for different data types, using a Message Broker channel name, which instructs that any HTTP request coming to that servlet will publish the message to that channel.
To learn more, see Event Generators in Using The WebLogic Integration Administration Console, which is located at the following URL:
http://download.oracle.com/docs/cd/E13214_01/wli/docs92/adminhelp/evntgen.html
![]() ![]() ![]() |