Using the CSR API involves
- using sbr_csr_create() to create one or more CSR service objects, based on a template used to construct requests, and which represents
- the CSR end-point (URL) that reports are being submitted to
- the type of report being submitted (ServiceType)
- using the CSR object and sbr_req_create() to create one or more request objects for managing requests
- using the CSR Request object
- (optional) to programatically override the template and amend the request content using the API
- to submit requests with sbr_req_submit()
- using the CSR Response API to query the response object
- extract the entire XML response string; or
- programatically query the response contents using the API
For example (this just uses the request template as is and extracts the response XML)...
Create the CSR object
ato_CfgMgr *ctxmgr = NULL;
:
errcode =
sbr_csr_create(ctx, &csr,
"lodge", serviceURL, CsrXmlTemplateBuffer);
:
struct _sbr_Request sbr_Request
The CSR request object used to submit a business report.
Definition: request.h:12
struct _sbr_Response sbr_Response
The CSR response object for a given sbr_CsrRequest.
Definition: response.h:12
SBR_CSR_EXPORT int sbr_csr_create(ato_Ctx *ctx, sbr_Csr **csr, const char *servicetype, const char *csrurl, const char *csrtemplate)
Create a CSR object from the XML stored in csrtemplate.
struct _sbr_Csr sbr_Csr
The CSR object used to interact with an SBR core services service to submit business reports.
Definition: include/sbrcsr/csr.h:14
The parameters are:
- the context
- the address of the CSR object to allocate
- the CSR servicetype - this must match an id of the ServiceType element in the Configuration
- the endpoint URL - if NULL then load from the configuration
- the buffer containing the XML string for the CSR template - if NULL then load from the file specified in the configuration
- Note
- The csr object must be freed when finished with - after freeing dependant request objects.
Create the CSR Request object
:
:
SBR_CSR_EXPORT int sbr_req_create(ato_Ctx *ctx, sbr_Request **request, sbr_Csr *csr)
Create a CSR request object based on the service type and template information of the CSR object.
- Note
- The request object must be freed when finished with.
Submit the Request
Prior to submitting a request, there are a variety of methods to set the content of the request. See the API for more details.
:
errcode =
sbr_req_submit(ctx, request, &response, certificate, privatekey, prooftoken, encryptedAssertion);
:
SBR_CSR_EXPORT int sbr_req_submit(ato_Ctx *ctx, sbr_Request *request, sbr_Response **response, ato_String *certificate, ato_String *privatekey, ato_String *prooftoken, ato_String *assertion)
Use a CSR request object to submit to the CSR service and return a CSR response.
The parameters are:
- the CSR Request
- the address of the CSR Response object to allocate
- the X509 certificate used for signing (sourced from the ATOAKM SDK in the section Getting credentials)
- the private key associated with the X509 certificate
- the prooftoken of a SecurityToken returned by an STS (sourced from the ATOSTM SDK in the section Getting a SecurityToken)
- the encryptedAssertion of a SecurityToken returned by an STS
- Note
- The response object must not be freed. It will be free when the associated request object is freed.
Query the Response
:
:
SBR_CSR_EXPORT int sbr_res_xml(ato_Ctx *ctx, sbr_Response *response, char **buffer)
This is a convenience method to extract the entire response as an XML string.
The parameters are:
- the CSR Response
- the address of the buffer to allocate to save the XML response to - must be freed by the caller
There are a variety of other methods to query the response object content. See the API for more details.
Cleanup
:
free(buffer);
sbr_csrreq_free(csrrequest);
SBR_CSR_EXPORT void sbr_csr_free(sbr_Csr *csr)
Free the CSR object if not NULL.