Passing client request to service callout with out creating new request

How to pass incoming client request to the Service callout with out creating new request? We are trying to avoid creating new request to save memory since we are handling larger set of data

0 3 560
3 REPLIES 3

Not applicable

service callout is used to fulfill one request which is having a dependency on the response of another service. For service callout, you need to set the required parameters for the request.

If you don't have any other backend then you can use a service callout response as a proxy response.

@Priyadarshi Ajitav Jena

Thanks for your response. As you explained above We are using service call out since it has dependency on the other service response. But we are look for while invoking another service instead creating new request pass on the existing(incoming request

Our use case.

We are planning to implement virus scan functionality. Our API first calls virus scan program using service call out and decides to move further or reject the request. In this process is there any possibility to pass in coming request as is to the Virus scan call?

Not applicable

You need one assign message policy to copy the request to another variable request and add the new request to the service-callout. I tried this and it worked for me. Below are the working codes.

the assign message policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
    <DisplayName>Assign Message-1</DisplayName>
    <Properties/>
    <Copy source="request">
        <Headers/>
        <FormParams/>
        <Payload>true</Payload>
        <!--<Path>true</Path>-->
        <QueryParams/>
        <ReasonPhrase>true</ReasonPhrase>
        <Verb>true</Verb>
        <Version>true</Version>
    </Copy>
    <AssignTo createNew="true" transport="http" type="request">myreq</AssignTo>
</AssignMessage>

the service callout policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-1">
    <DisplayName>Service Callout-1</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myreq">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://************************</URL>
    </HTTPTargetConnection>
</ServiceCallout>