HTTP Client POST Service
The HTTP Client POST service sends HTTP POST requests to a trading partner's HTTP server via the perimeter server. This service works with the HTTP Client Begin service and the HTTP Client End service and through an instance of the HTTP Client adapter.
The following table provides an overview of the HTTP Client POST service:
System name | HTTP Client POST Service |
---|---|
Graphical Process Modeler (GPM) categories | All Services, B2B Protocols > HTTP Client |
Description | The HTTP Client POST Service sends HTTP POST requests to a trading partner's HTTP server via the perimeter server. This service works with the HTTP Client Begin service and the HTTP Client End service, and through an instance of the HTTP Client adapter. |
Business usage | A business user would use the HTTP Client POST Service to place documents on a trading partner's HTTP server. |
Usage example | A business process is executed that generates a document to be transferred to a trading partner using the HTTP protocol. The application initiates a session with the trading partner using the HTTP Client Adapter and uses the HTTP Client POST Service to place the data on the trading partner's HTTP server. |
Preconfigured? | No |
Requires third-party files? | No |
Platform availability | All supported platforms for Sterling B2B Integrator |
Related services | Related services:
|
Application requirements | An HTTP server must exist at the external trading partner location. |
Initiates business processes? | No |
Invocation | This service is invoked from a business process. |
Business process context considerations | None |
Returned status values | Returned status values:
|
Restrictions | None |
Persistence level | Default |
Testing considerations | To test this service, run the HTTPClientDemoAllServices business process and verify that it completes successfully. For more information about the HTTPClientDemoAllServices business process, see the HTTP Client adapter. Debug information for this service can be found in the HTTP Client adapter and services log files. |
Implementing the HTTP Client POST Service
- Create an HTTP Client POST service configuration. For information, see Managing Services and Adapters.
- Configure the HTTP Client POST service. For information, see Configuring the HTTP Client POST Service.
- Use the HTTP Client POST service in a business process.
Configuring the HTTP Client POST Service
To configure the HTTP Client POST service, you must specify field settings in the GPM:
Field | Description |
---|---|
Config | Name of the service configuration. |
DocumentId | A document ID to use with this instance of the HTTP Client POST service. Optional. |
RawRequest | Whether to include the HTTP header metadata in
the primary document. Optional. Valid values:
Note: This parameter does not apply if MethodType
is set to GET.
|
RawResponse | Whether to include the HTTP Server response headers
in the response document. Optional. Valid values:
|
ResponseTimeout | Number of seconds the HTTP Client adapter will
wait for a response. Optional. Any numeric value is valid. Note: The
value entered for this parameter overrides the Timeout setting in
the HTTP Client adapter configuration.
|
SessionToken | Specifies the identifier for the session established between the HTTP Client Adapter and an HTTP server. Required. |
ShowResponseCode | Whether to include the HTTP response status code
as the first line in the primary document. Optional. Valid values:
|
LineBreak | Allows you to specify what type of line break is
used in the message. Optional. Valid values:
|
URI | Uniform Resource Indicator (URI) representing the HTTP server. Required. |
Cookie | Identifies the cookie to use in cases where the previous POST needs page redirection (returns 300 range response). The cookie value is passed from the response header Set-Cookie. The Post Service uses the Cookie parameter and creates the Cookie header in the next request. Valid values are cookies separated by semi-colon (cookie1;cookie2;cookie3). Optional. |
stripDefaultPortFromRequestHostHeader | Whether to include the port information in the HTTP host header if the port is
the default port (port 80 for HTTP, port 443 for HTTPS). Optional. Valid values:
|
Output from Business Process to Service
The following table contains the parameters passed from the business process to the HTTP Client POST service:
Field | Description |
---|---|
DocumentId | A document ID to use with this instance of the HTTP Client POST service. Optional. |
RawRequest | Whether to include the HTTP header metadata in
the primary document. Optional. Valid values:
Note: This parameter does not apply if MethodType
is set to GET.
|
RawResponse | Whether to include the HTTP Server response headers
in the response document. Optional. Valid values:
|
ResponseTimeout | Number of seconds the HTTP Client adapter will
wait for a response. Optional. Any numeric value is valid. Note: The
value entered for this parameter overrides the Timeout setting in
the HTTP Client adapter configuration.
|
SessionToken | Specifies the identifier for the session established between the HTTP Client Adapter and an HTTP server. Required. |
ShowResponseCode | Whether to include the HTTP response status code
as the first line in the primary document. Optional. Valid values:
|
LineBreak | Allows you to specify what type of line break is
used in the message. Optional. Valid values:
|
URI | Uniform Resource Indicator (URI) representing the HTTP server. Required. |
Cookie | Identifies the cookie to use in cases where the previous POST needs page redirection (returns 300 range response). The cookie value is passed from the response header Set-Cookie. The Post Service uses the Cookie parameter and creates the Cookie header in the next request. |
Business Process Examples
The following example business process illustrates by using commands supported by the HTTP Client POST service:
<process name="HTTPClientPOSTServiceExample">
<sequence>
[[Insert Begin session operation here]]
<operation name="HTTP Client POST Service">
<participant name="HTTPClientPOSTService"/>
<output message="HTTPClientPostServiceTypeInputMessage">
<assign to="DocumentId">DocumentID</assign>
<assign to="RawRequest">true</assign>
<assign to="RawResponse">true</assign>
<assign to="ResponseTimeout">60</assign>
<assign to="SessionToken">SessionToken</assign>
<assign to="ShowResponseCode">true</assign>
<assign to="LineBreak">LF</assign>
<assign to="URI">URI</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
[[Insert End session operation here]]
</sequence>
</process>
The following business process provides an example of using the Cookie parameter:
<process name="HTTP_To_advancepcsrx">
<!-- Loop Invariant. -->
<rule name="haveMoreCookie1">
<condition> string(counterCookie) <=
count(HTTPClientPostServiceResults/ServerResponse/Headers/
Set-Cookie/node()) </condition>
</rule>
<sequence>
<operation name="HTTP Client Begin Session Service">
<participant name="HTTPClientBeginSession"/>
<output message="HTTPClientBeginSessionServiceTypeInputMessage">
<assign to="CACertificateId">sgmillenia:13582d:10682043f1d:-73bd
</assign>
<assign to="CipherStrength">all</assign>
<assign to="HTTPClientAdapter">HTTPClientAdapter</assign>
<assign to="SSL">Must</assign>
<assign to="RemoteHost">webtransport.advancepcsrx.com</assign>
<assign to="RemotePort">443</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientBeginSessionServiceResults" from="*"></assign>
</input>
</operation>
<!-- Use FSA to pick up the input file -->
<operation name="Import Document Request">
<participant name="TEST_FILE_SYSTEM_ADAPTER"/>
<output message="FileSystemInputMessage">
<assign to="Action">FS_COLLECT</assign>
<assign to="collectionFolder" from="'/ais_local/share/sli'"></assign>
<assign to="filter" from="'AdvancePCS_URI.txt'"></assign>
<assign to="useSubFolders">false</assign>
<assign to="bootstrap">false</assign>
<assign to="deleteAfterCollect">false</assign>
<assign to="." from="*"></assign>
</output>
<input message="FileSystemOutputMessage">
<assign to="." from="*"></assign>
</input>
</operation>
<!-- Set document content type/subtype -->
<operation name="SetContenType">
<participant name="GetDocumentInfoService"/>
<output message="xout">
<assign to="." from="*"></assign>
<assign to="DocumentContentType">application</assign>
<assign to="DocumentContentSubType">x-www-form-urlencoded</assign>
</output>
<input message="xin">
<assign to="docInfo" from="*"></assign>
</input>
</operation>
<!-- POST to URI /template/login to login the webpage -->
<operation name="Http Client Post Service">
<participant name="HTTPClientPost"/>
<output message="HTTPClientPostServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="URI">/template/login</assign>
<assign to="RawResponse">true</assign>
<assign to="ResponseTimeout">120</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientPostServiceResults"
from="*" append="true"></assign>
</input>
</operation>
<!-- concat the cookie from the POST Response -->
<assign to="counterCookie">1</assign>
<assign to="Cookie" from="''"/>
<choice>
<select>
<case ref="haveMoreCookie1" activity="AppendCookie1"/>
</select>
<sequence name="AppendCookie1">
<assign to="Cookie" from="concat(string(Cookie), substring-before
(//HTTPClientPostServiceResults/ServerResponse/Headers/Set-Cookie[number
(//counterCookie)],';'),'; ')"/>
<assign to="counterCookie" from="number(counterCookie) + 1"/>
<choice>
<select>
<case ref="haveMoreCookie1" activity="Repeat1"/>
</select>
<repeat name="Repeat1" ref="AppendCookie1"/>
</choice>
</sequence>
</choice>
<!-- release Primary Document before GET -->
<operation>
<participant name="ReleaseService"/>
<output message="releaseRequest">
<assign to="TARGET" from="'PrimaryDocument'"/>
</output>
<input message="releaseResponse"/>
</operation>
<!-- GET URI / to reach the final page -->
<operation name="Http Client Get Service">
<participant name="HTTPClientGet"/>
<output message="HTTPClientGetServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="URI">/</assign>
<assign to="RawResponse">true</assign>
<assign to="ResponseTimeout">1200</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientGetServiceResults" from="*" append="true">
</assign>
</input>
</operation>
<operation name="HTTP Client End Session Service">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientEndSessionServiceResults" from="*"
append="true"></assign>
</input>
</operation>
<onFault>
<sequence name="End Session">
<operation name="HTTP Client End Session Service">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientEndSessionServiceResults" from="*"></assign>
</input>
</operation>
</sequence>
</onFault>
</sequence>
</process>
The following business process provides an example of using the GetDocumentInfoService to set the content-type/subtype of the request document. It is important to put the output parameters of GetDocumentInfoService into a parent node, such as "docinfo."
The GetDocumentInfoService returns a node called DocumentId to the process data. This is the ID of the original document object without the content-type and sub-type set. If this node is directly under the root of Process Data, the HTTP Client Post service will attempt to retrieve the original document object using the document ID instead of the Primary Document. If DocumentId node is returned under "docinfo" node, the HTTP Client Post service does not use the document from DocumentId. Instead the service retrieves the correct document that was set with the correct content-type/subtype from the primary document.
<process name="HttpClient_SetContentType">
<sequence>
<!-- Set document content type/subtype -->
<operation name="SetContenType">
<participant name="GetDocumentInfoService"/>
<output message="xout">
<assign to="." from="*"></assign>
<assign to="DocumentContentType">text</assign>
<assign to="DocumentContentSubType">xml</assign>
</output>
<input message="xin">
<assign to="docInfo" from="*"></assign>
</input>
</operation>
<operation name="HTTP Client Begin Session Service">
<participant name="HTTPClientBeginSession"/>
<output message="HTTPClientBeginSessionServiceTypeInputMessage">
<assign to="HTTPClientAdapter">HTTPClientAdapter</assign>
<assign to="RemoteHost">10.235.18.103</assign>
<assign to="RemotePort">37133</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientBeginSessionServiceResults" from="*"></assign>
</ input>
</operation>
<operation name="Http Client Post Service">
<participant name="HTTPClientPost"/>
<output message="HTTPClientPostServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="URI">/hello</assign>
<assign to="RawRequest">false</assign>
<assign to="RawResponse">true</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientPostServiceResults" from="*" append="true">
</assign>
</input>
</operation>
<operation name="HTTP Client End Session Service">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientEndSessionServiceResults" from="*"
append="true"></assign>
</input>
</operation>
<onFault>
<sequence name="End Session">
<operation name="HTTP Client End Session Service">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="SessionToken"
from="HTTPClientBeginSessionServiceResults/SessionToken/text()">
</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="HTTPClientEndSessionServiceResults" from="*">
</assign>
</input>
</operation>
</sequence>
</onFault>
</sequence>
</process>
The following business process provides an example of specifying parameters in URI of the HTTP Client POST service. The URI is:
/getraf/portal_getraf/processGentranData?
UID=f87db70048484b0fe6348eaebbf62281&status=0&errorMsg=Erro
The URI in this example has three parameters:
Parameter | Value |
---|---|
ei | utf-8 |
fr | slv8-msgr |
p | http%20POST%20examples |
The business process is the following:
<process name = "test_http_post">
<sequence>
<operation name="HTTP Client Begin Session Service">
<participant name="HTTPClientBeginSession"/>
<output message="HTTPClientBeginSessionServiceTypeInputMessage">
<assign to="HTTPClientAdapter">HTTPClientAdapter</assign>
<assign to="RemoteHost">search.yahoo.com</assign>
<assign to="RemotePort">80</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="HTTP Client POST Service">
<participant name="HTTPClientPost"/>
<output message="HTTPClientPostServiceTypeInputMessage">
<assign to="RawRequest">true</assign>
<assign to="SessionToken" from="/ProcessData/SessionToken/text()">
</assign>
<assign to="ShowResponseCode">true</assign>
<assign to="URI">/search?ei=utf-8&fr=slv8-msgr&p=
http%20POST%20examples</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
<operation name="HTTP Client End Session Service">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="SessionToken" from="/ProcessData/SessionToken/text()">
</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
</sequence>
</process>
Activity Types for the HTTP Client POST Service
- POST – Requests that the server accept the entity enclosed in the request as a new subordinate of the resource identified by the URI in the request line.