You are here: Reference > Rule types > Service HTTP rules > More about Service HTTP rules

More about Service HTTP rules
 

  1. About 
  2. New 
  3. Service 
  4. Request 
  5. Response 
  6. History 
  7. More... 

Invoking a service rule

To send a request to an HTTP service rule, use the URL of the PRHTTPService servlet. Append the three-part key to the rule to the URL. Use the following syntax:

http://servername:portnumber/contextroot/PRHTTPService/packageName
/className/methodName

For example:

http://MyServer:8080/prweb/PRHTTPService/SampleHTTP/Phonebook/AddContact

Authentication

When the service runs as an authenticated user, the external application sending the request must include the username and password of an Operator ID in the request. The external application can send these values either in an HTTP header, or appended to the URL as name/value pairs for the parameters UserIdentifier and Password. The value of the password must be base64-encoded.

Stateful sessions

When the session state in a service package is set to Stateful, the service returns a cookie in the response with the Set-Cookie HTTP header. The cookie contains the Requestor ID of the requestor that processed the first request, with the prefix "PegaRULES." For another request to access the same session data, the external application must include the PegaRULES cookie in the header of that request.

Custom cookies and stateful sessions

A response can contain only one Set-Cookie header. If a Set-Cookie is set in the data mapping on the Response tab, the Pega Platform does not set the PegaRULES cookie for you. So if the services run in a stateful session and you need to return custom cookies, your rules are also responsible for constructing the PegaRULES cookie.

Create the cookie string by concatenating all the cookies to be sent, including the PegaRULES cookie, into one string. The value of the PegaRULES cookie must be the requestor ID. For example: PegaRULES=H40F706525721982DE3C8530D6DC64FCD.

Get the value of the requestor ID from the pzRequestorId property on the pxRequestor page, which is always present on the clipboard. This can be accomplished either by having the service activity set a clipboard property, or through a Rule-Utility-Function. Then, use the Response tab to configure a Set-Cookie header that contains the string with the values of all the cookies.

Performance logging

You can collect preformance statistics about the resources used by a service in a Comma-Separated-Values (CSV) file, accessed from the Log menu. See Performance tool — Statistics for services in the SERVICES-PAL log.

About Service HTTP rules