It's common for JSON services to use RESTful interface design principles; as such, the URI and HTTP method will often combine to indicate what is to be done.
This differs from the common document-literal SOAP/HTTP pattern, where the HTTP method will always be POST
, the URI will be constant for all operations exposed by a service, and the operation will be selected by the outer-most element inside the SOAP body or the SOAPAction header.
This difference means that we'll often need to do some extra preparation before calling out to a JSON service, so that the HTTP method and the URI are correctly configured.
We'll be building on the previous recipes, so we'll assume that you already have an OSB project in OEPE, with an HTTP business service, and a proxy service that invokes it using a Service Callout.
i. First, click on <Expression> to open the XQuery/XSLT Expression Editor and enter the following:
<http:http-method>PUT</http:http-method>
ii. Next, ensure the Location attribute is set to as first child off.
iii. Click on <XPath> to open the XPath Expression Editor. Within the variable structure browse to outbound | $outbound | transport | request | request – http and drag it on to the Expression, as shown in the following screenshot:
iv. Click on OK.
v. Next, set In Variable to outbound
.
relative-URI
element may be added to the outbound variable to provide this information to the business service.To append /1
to the end of the URI, drag an Insert activity to the Request Action path of the Service Callout. Configure the Properties of the Insert activity (as in step 2) to have the values listed in the following table:
Field |
Value |
---|---|
Expression |
|
Location |
as first child of |
XPath |
|
In Variable |
|
If the Endpoint URI configured for the business service is http://example.org:8091/CreditCardService/CreditCardJSON_1.0
, the outgoing call will now be made to the following URL:
http://example.org:8091/CreditCardService/CreditCardJSON_1.0/1
.
It is, of course, much more likely that you will dynamically construct the relative-URI value based on the received request.
The ./ctx:transport/ctx:request
element of the outbound
variable is used to supply transport-specific metadata to the business service, to influence how it makes the outgoing service invocation.
In some cases it will be necessary to completely override the business service's endpoint URI.
Assuming that the URI to use has been assigned to a variable requestURI
earlier in the proxy service message flow, the endpoint URI override is performed as follows:
$requestURI
.