Batching multiple requests in XML requests

You can combine multiple requests in a single message by using a <BatchRequest> wrapper tag. A batch request sequentially runs each request inside of it on the same connection. It can improve performance by decreasing the amount of network traffic required for multiple requests.

Batch requests use a single set of authentication data for all sub-requests (defined at the batch request level). Any sub-requests nested in the batch request run on the connection obtained by using that authentication data.

If you nest sub-requests inside of transaction tags, then all of the sub-requests roll back if one of them fails.

To batch multiple requests in one message, create a <BatchRequest> that identifies the following information (text in brackets are optional):

<BatchRequest>
  <AuthenticationData> ... </AuthenticationData>
[ <!-- Insert any number of requests here --> ]
[ <Transaction><!-- Insert any number of requests here --></Transaction> ]
</BatchRequest>

<BatchRequest> elements

<AuthenticationData> (required)
Identifies the content server (<ServerDef>), a valid user ID (<UserID>), and password (<Password>)--or a WebSphere® SSO credential.
<Transaction> (optional)
Identifies which requests to undo during a failure. If any request within the <Transaction> tag fails, then all requests in the same tag rollback. You cannot nest <Transaction> tags.

The following example deletes one policy and one claim in the same <BatchRequest>:

Example: XML request

<BatchRequest 
xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
<AuthenticationData connectString="SCHEMA=ICMADMIN" configString="">
  <ServerDef><ServerType>ICM</ServerType>
  <ServerName>icmnlsdb</ServerName></ServerDef><LoginData>
  <UserID>icmadmin</UserID><Password>passw0rd</Password></LoginData>
</AuthenticationData>
<Transaction>
<Requests>

<DeleteItemRequest 
  xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
  <AuthenticationData connectString="SCHEMA=ICMADMIN" configString="">
  ...
  </AuthenticationData>
  <Item URI="http://hostname/CMBGenericWebService/CMBGetPIDUrl?pid=93 
  3 ICM8 icmnlsdb13 XYZ_InsPolicy59 26 A1001001A04I10B44211H0825818 
  A04I10B44211H082581 14 1029&server=icmnlsdb&dsType=ICM" />
</DeleteItemRequest>

<DeleteItemRequest 
  xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
  <AuthenticationData connectString="SCHEMA=ICMADMIN" configString="">
  ...
  </AuthenticationData>
  <Item URI="http://hostname/CMBGenericWebService/CMBGetPIDUrl?pid=93 
  3 ICM8 icmnlsdb13 XYZ_ClaimForm59 26 A1001001A04I10B44213F1658218 
  A04I10B44213F165821 14 1027&server=icmnlsdb&dsType=ICM" />
</DeleteItemRequest>

</Requests>
</Transaction>
</BatchRequest>

As a result, IBM® Content Manager returns an XML <BatchReply> that wraps the replies from every XML request that you batched.

Example: XML reply

<BatchReply 
xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
<RequestStatus success="true"></RequestStatus>
<Transaction>
<Replies>

<DeleteItemReply 
  xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
<RequestStatus success="true"></RequestStatus>
</DeleteItemReply>
<DeleteItemReply 
xmlns="http://www.ibm.com/xmlns/db2/cm/beans/1.0/schema">
<RequestStatus success="true"></RequestStatus></DeleteItemReply>

</Replies>
</Transaction>
</BatchReply>