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.
Figure 1 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 WebSphere MQ message.
Figure 1. Example of an HTTP POST request to a queue POST /msg/queue/myQueue/ HTTP/1.1Host: www.example.orgContent-Type: text/plainx-msg-correlID: 1234567890Content-Length: 50Here's my message body that will appear on the queue.
Figure 2 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 OKDate: Wed, 2 Jan 2007 22:38:34 GMTServer: Apache-Coyote/1.1 WMQ-HTTP/1.1 JEE-Bridge/1.1Content-Length: 0请求的协议格式和请求的响应格式
The HTTP POST operation puts a message on a WebSphere® MQ queue, or publishes a message to a topic.
SyntaxRequest>>-POST-- --| Path |-- --HTTP version--CRLF---------------------> .-CRLF---------------. .-CRLF---------------. V | V | >----+----------------+-+----+----------------+-+---------------> '-general-header-' '-request-header-' .-CRLF----------------------------. .-CRLF----. V | V | >----+-----------------------------+-+--CRLF----Message-+------>< '-| entity header (Request) |-' Path|--/--contextRoot--/-------------------------------------------->>--msg/--+-queue/--queueName--+-------------+-+--/--------------| | '-@--qMgrName-' | '-topic/--topicName------------------' entity-header (Request)|--+----------------------------------------------+-------------| +-standard entity-header-- --entity-value------+ +-x-msg-class-- --message type-----------------+ +-x-msg-correlId-- --correlation ID------------+ +-x-msg-encoding-- --encoding type-------------+ +-x-msg-expiry-- --duration--------------------+ +-x-msg-format-- --message format--------------+ +-x-msg-msgId-- --message ID-------------------+ +-x-msg-persistence-- --persistence------------+ +-x-msg-priority-- --priority class------------+ +-x-msg-replyTo-- --reply-to queue-------------+ +-x-msg-require-headers-- --entity header name-+ '-x-msg-usr-- --user properties----------------' Note:
Response>>-HTTP version-- --HTTP Status-Code-- --HTTP Reason-Phrase--CRLF--> .-CRLF---------------. .-CRLF----------------. V | V | >----+----------------+-+----+-----------------+-+--------------> '-general-header-' '-response-header-' .-CRLF-----------------------------. V | >----+------------------------------+-+------------------------>< '-| entity-header (Response) |-' entity-header (Response)|--+-----------------------------------------+------------------| +-standard entity-header-- --entity-value-+ +-x-msg-class-- --message type------------+ +-x-msg-correlId-- --correlation ID-------+ +-x-msg-encoding-- --encoding type--------+ +-x-msg-expiry-- --duration---------------+ +-x-msg-format-- --message format---------+ +-x-msg-msgId-- --message ID--------------+ +-x-msg-persistence-- --persistence-------+ +-x-msg-priority-- --priority class-------+ +-x-msg-replyTo-- --reply-to queue--------+ +-x-msg-timestamp-- --HTTP-date-----------+ '-x-msg-usr-- --user properties-----------' HTTP POST方式实现如下:
HTTP POST 发布主题请求协议和响应协议 http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21220_.htm 请求响应头各个字段的含义的讲解 http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21250_.htm 响应错误处理 http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21340_.htm |