¿why does my service callout not work?

apiguru
Participant II

I'm trying to call an another service internally using proxy chain. the intermediate service receives the call but not the URI. When I look at the policy in trace I see the complete URI.

Here's what I'm doing in last 2 steps

<AssignMessage name="Verify_Request">
    <DisplayName>Verify_Request</DisplayName>
    <Properties/>
    <Set>
        <Verb>GET</Verb>
        <Path>/abc/bbc/api/def</Path>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
<ServiceCallout  name="SC-verify">
    <Request clearPayload="true">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <LocalTargetConnection>
        <APIProxy>VerificationProxy</APIProxy>
        <ProxyEndpoint>default</ProxyEndpoint>
    </LocalTargetConnection>
</ServiceCallout>
1 1 207
1 REPLY 1

If you want the ServiceCallout policy to reference a particular request object, you must create a new one with AssignMessage. That means

<AssignTo 
   createNew="true" 
   transport="http" 
   type="request">my_sc_request</AssignTo>

Also you need to then reference that request in the ServiceCallout policy. like this

  <Request clearPayload="false" variable="my_sc_message"/>

Putting it together, ...

AssignMessage

<AssignMessage name="AM-Verify-Request">
    <Set>
        <Verb>GET</Verb>
        <Path>/abc/bbc/api/def</Path>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="true" transport="http" type="request">verifyRequest</AssignTo>
</AssignMessage>

ServiceCallout

<ServiceCallout  name="SC-verify">
    <Request clearPayload="false" variable="verifyRequest"/>
    <Response>calloutResponse</Response>
    <LocalTargetConnection>
        <APIProxy>VerificationProxy</APIProxy>
        <ProxyEndpoint>default</ProxyEndpoint>
    </LocalTargetConnection>
</ServiceCallout>

I suggest that you follow a naming convention for your policies. SC => ServiceCallout, and AM=> AssignMessage. And similarly for RaiseFault, KeyValueMapOperations, and etc.