In this post let us see how to send and consume HTTP POST request using SOA 11g.
Sample attached with this post will send a file in base64encoded format as a HTTP POST request and the same will be consumed by another BPEL process which is exposed to consume the file in HTTP protocol.
We will use the following XML schema (XSD) to build our HTTP POST service;
Exposing a SOA 11g BPEL process as a HTTP service (POST):
Step 1: Create a SOA Project with empty composite and name it "HttpPostRestService"
Step 2: Drag and Drop a HTTP Binding adapter on the "Exposed Services" swimlane in the SOA composite (SCA)
Step 3: Choose Next in the Welcome page of the wizard
Step 4: Enter service name
Step 5: Choose "Define from operation and schema (specified later)" option
Step 6: Choose the following options and click Next
Type: Service [You will choose "Reference" if you need to consume a HTTP REST service]
Operation Type: Request-Response [For 2-way communication. Choose One-way if the service doesn't return a response]
Operation Name: Defaults to Request-Response [You can change it as you please]
Verb: POST [This specifies the HTTP method. You have 2 options GET/POST]
Payload Type: XML [For HTTP POST, you get 2 options url-encoded and XML. Since our payload will be huge, url-encoded will not make sense due to size restrictions]
Step 7: In the Messages dialog, select the RestPost.xsd, <Input> and <Response> XML elements for "Request Message Schema" & "Response Message Schema" respectively.
Step 8: In the summary page, click "Finish" to complete service
Now that we have completed the HTTP binding service adapter which will expose the SOA 11g BPEL process as a HTTP service, you can choose to build a BPEL process which will consume the POST message for further processing.
Deploy the completed process and obtain the HTTP service URL from EM console. We will invoke this service from another SOA composite.
Consuming a HTTP (POST) service in SOA 11g BPEL process:
Step 1: Create a SOA Project with empty composite and name it "InvokeHttpPostService"
Step 2: Drag and Drop a HTTP Binding adapter on to the "External References" swimlane in the SOA composite (SCA)
Step 3: Choose Next in the Welcome page of the wizard
Step 4: Enter service name
Step 5: Choose "Define from operation and schema (specified later)" option
Step 6: Choose the following options and click Next
Type: Reference [Since we are consuming a HTTP service - POST]
Operation Type: Request-Response [Default selection for references]
Operation Name: Request-Response [Default]
Verb: POST [This specifies the HTTP method that will be invoked]
Payload Type: XML
Endpoint: Provide the HTTP URL for the REST service to be invoked.
Step 7: In the Messages dialog, select the RestPost.xsd, <Input> and <Response> XML elements for "Request Message Schema" & "Response Message Schema" respectively.
Step 8: In the summary screen, click Finish to complete the service adapter
Now, build and complete your SOA composite which will invoke a HTTP service using POST method.
Sample attached with this post will send a file in base64encoded format as a HTTP POST request and the same will be consumed by another BPEL process which is exposed to consume the file in HTTP protocol.
We will use the following XML schema (XSD) to build our HTTP POST service;
Exposing a SOA 11g BPEL process as a HTTP service (POST):
Step 1: Create a SOA Project with empty composite and name it "HttpPostRestService"
Step 2: Drag and Drop a HTTP Binding adapter on the "Exposed Services" swimlane in the SOA composite (SCA)
Step 3: Choose Next in the Welcome page of the wizard
Step 4: Enter service name
Step 5: Choose "Define from operation and schema (specified later)" option
Step 6: Choose the following options and click Next
Type: Service [You will choose "Reference" if you need to consume a HTTP REST service]
Operation Type: Request-Response [For 2-way communication. Choose One-way if the service doesn't return a response]
Operation Name: Defaults to Request-Response [You can change it as you please]
Verb: POST [This specifies the HTTP method. You have 2 options GET/POST]
Payload Type: XML [For HTTP POST, you get 2 options url-encoded and XML. Since our payload will be huge, url-encoded will not make sense due to size restrictions]
Step 7: In the Messages dialog, select the RestPost.xsd, <Input> and <Response> XML elements for "Request Message Schema" & "Response Message Schema" respectively.
Step 8: In the summary page, click "Finish" to complete service
Now that we have completed the HTTP binding service adapter which will expose the SOA 11g BPEL process as a HTTP service, you can choose to build a BPEL process which will consume the POST message for further processing.
Deploy the completed process and obtain the HTTP service URL from EM console. We will invoke this service from another SOA composite.
Consuming a HTTP (POST) service in SOA 11g BPEL process:
Step 1: Create a SOA Project with empty composite and name it "InvokeHttpPostService"
Step 2: Drag and Drop a HTTP Binding adapter on to the "External References" swimlane in the SOA composite (SCA)
Step 3: Choose Next in the Welcome page of the wizard
Step 4: Enter service name
Step 5: Choose "Define from operation and schema (specified later)" option
Step 6: Choose the following options and click Next
Type: Reference [Since we are consuming a HTTP service - POST]
Operation Type: Request-Response [Default selection for references]
Operation Name: Request-Response [Default]
Verb: POST [This specifies the HTTP method that will be invoked]
Payload Type: XML
Endpoint: Provide the HTTP URL for the REST service to be invoked.
Step 7: In the Messages dialog, select the RestPost.xsd, <Input> and <Response> XML elements for "Request Message Schema" & "Response Message Schema" respectively.
Step 8: In the summary screen, click Finish to complete the service adapter
Now, build and complete your SOA composite which will invoke a HTTP service using POST method.
Source code can be downloaded here
Let me know your thoughts in comments section.