HTTP POST: IBM MQ bridge for HTTP command

The HTTP POST operation puts a message on an IBM MQ queue, or publishes a message to a topic.


Syntax

Request

POST pathHTTP versionCRLF CRLF general-header CRLF request-header CRLF entity-header (Request)CRLF CRLFMessagePath / contextRoot / msg/ queue/queueName@qMgrNametopic/topicName / entity-header (Request)standard entity-header entity-valuex-msg-class message typex-msg-correlId correlation IDx-msg-encoding encoding typex-msg-expiry durationx-msg-format message formatx-msg-msgId message IDx-msg-persistence persistencex-msg-priority priority classx-msg-replyTo reply-to queuex-msg-require-headers entity header namex-msg-usr user properties Note:
  1. If a question mark (?) is used it must be substituted with %3f. For example, orange?topic should be specified as orange%3ftopic.
  2. @ qMgrName is only valid on an HTTP POST

Response

HTTP version HTTP Status-Code HTTP Reason-PhraseCRLF CRLF general-header CRLF response-header CRLF entity-header (Response)entity-header (Response)standard entity-header entity-valuex-msg-class message typex-msg-correlId correlation IDx-msg-encoding encoding typex-msg-expiry durationx-msg-format message formatx-msg-msgId message IDx-msg-persistence persistencex-msg-priority priority classx-msg-replyTo reply-to queuex-msg-timestamp HTTP-datex-msg-usr user properties


Request parameters

    request-header
    See HTTP/1.1 - 5.3 Request Header Fields. The Host field is mandatory on an HTTP/1.1 request. It is often automatically inserted by the tool we use to create a client request.
    entity-header (Request)
    See HTTP/1.1 - 7.1 Entity Header Fields. One of the entity headers listed in the Request syntax diagram. The Content-Length and Content-Type should be inserted in a request, and are often inserted automatically by the tool we use to create a client request. The Content-Type must match the type defined in the x-msg-class custom entity-header, if it is specified.
    Message
    Message to put onto the queue, or publication to post to a topic.


Response parameters


Description

If no x-msg-usr header is included, and message class is BYTES or TEXT, the message put on the queue does not have an MQRFH2.

Use HTTP entity and request headers in the HTTP POST request to set the properties of the message that is put onto the queue. We can also use x-msg-require-headers to request which headers are returned in the response message.

If the HTTP POST request is successful, the entity of the response message is empty and its Content-Length is zero. The HTTP status code is 200 OK.

If the HTTP POST request is unsuccessful, the response includes an IBM MQ bridge for HTTP error message and an HTTP status code. The IBM MQ message is not put on the queue or topic.


HTTP POST example

HTTP POST puts a message to a queue, or a publication to a topic. The HTTPPOST Java sample is an example an HTTP POST request of a message to a queue. Instead of using Java, you could create an HTTP POST request using a browser form, or an AJAX toolkit instead.

The following figure shows an HTTP request to put a message on a queue called myQueue. This request contains the HTTP header x-msg-correlId to set the correlation ID of the IBM MQ message.

Figure 1. Example of an HTTP POST request to a queue
POST /msg/queue/myQueue/ HTTP/1.1
Host: www.example.org
Content-Type: text/plain
x-msg-correlID: 1234567890
Content-Length: 50

Here is my message body that is posted on the queue.

The following figure shows the response sent back to the client. There is no response content.

Figure 2. Example of an HTTP POST response
HTTP/1.1 200 OK
Date: Wed, 2 Jan 2007 22:38:34 GMT
Server: Apache-Coyote/1.1 WMQ-HTTP/1.1 JEE-Bridge/1.1
Content-Length: 0