Introducing service call out policy in api proxy

Not applicable

I am using service callout policy in one of the proxy deployed in apigee.

Proxy configuration:

Proxy end point base : /ngen-customer-microservice-dev1.cfapps.maxng-dev.maximus.com

Target end point : https://ngen-customer-microservice-dev1.cfapps.maxng-dev.maximus.com

Service callout Policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServiceCallout async="false" continueOnError="false" enabled="true" name="Calling-Customer-Service"> <DisplayName>Calling Customer Service</DisplayName> <Properties/> <Request clearPayload="true" variable="CustomerRequest"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Set> <Verb>POST</Verb> <Headers> <!-- We need to Base64 encode the client id and secret in the format "client id:secret" --> <Header name="Authorization">{CustomerRequest.header.Authorization}</Header> <Header name="Content-Type">application/json</Header> </Headers> <!-- <Payload contentType="application/json"> <request> <firstName>ashraf</firstName> <lastName>abedin</lastName> </request> </Payload>--> <Payload contentType="application/json" variableSuffix="#" variablePrefix="%">{"firstName":"ashraf"}</Payload> </Set> </Request> <Response>calloutResponse</Response> <HTTPTargetConnection> <Properties/> <URL>https://ngen-customer-microservice-dev1.cfapps.maxng-dev.maximus.com/app/crm/customer/customer</URL> </HTTPTargetConnection> </ServiceCallout>

I am getting a lot of transactions in the trace section which I believe is building the traffic in the apigee because of which we are not able to see the trace session for any of the other proxy.

Solved Solved
0 3 413
1 ACCEPTED SOLUTION

I am getting a lot of transactions..

It seems to me, if you are using the same endpoint for the proxy, and for the target, you have a looping construct. A Proxy that calls itself. This is probably not what you want.

You should modify the target.

What are you really trying to do?

View solution in original post

3 REPLIES 3

I am getting a lot of transactions..

It seems to me, if you are using the same endpoint for the proxy, and for the target, you have a looping construct. A Proxy that calls itself. This is probably not what you want.

You should modify the target.

What are you really trying to do?

Thanks for your help. I am working as server side developer.

I am working on the 4 micro services (customer,address,email,phone) in my current project.

I need to implement the search in a fashion that if end user enter any of the search criteria (i.e. customer info, address info, email , phone) , mesh up logic should be capable of giving correct result. The payload is shown below

{customer: { firstname:"abc", "lastName":"sdg", "ssn":"514"},

address:{"street" :"" ,city:""},

phone:{phonenumber:"1424",

email:{"emailId":"test@abc.com"}

}.

Each address, phone and email is linked to customer using a customer Id.

Customer id is foreign key in address, email, phone tables and primary key in the customer table

address data is in address DB, email in Email db, phone in phone DB and customer in customer DB (Repository pattern of spring boot is used that's why separate DB for separate service)


Current implementation scenario is explained below


I am passing "address":{"street":"3rd Block"} as my request from postman. I am tracking the request in the trace tab after proxy creation and deployment. In the develop tab, I Introduced Service callout Policy to proxy as soon as I am receiving the request. After getting the service response, I retrieved the customerID from the response using Extract Message Policy. After that I used the JS policy to set the customerID in the context. Then again service call out policy is introduced to call the particular customer . I get the response also .

1. How to merge these two responses?

2. How to implement mesh up for all conditions i.e. combination of the customer, address, phone , email?

3.How to introduce pagination i.e. which policy support pagination feature?

4. How to pass the PathParam in the request in the service call out policy?

Hi Ashraf

Do you still have questions? This answer is now marked "Accepted", which usually means "the question has been answered."

But in your comment you asked further questions. I'm not clear. Anyway I'll provide some brief answers in case you are still wondering.

1. Merging JSON responses can be done with a JavaScript callout, using logic like:

var obj1 = JSON.parse(context.getVariable('jsonResponse1.content'));
var obj2 = JSON.parse(context.getVariable('jsonResponse2.content'));
for (prop in obj2) {
    obj1[prop] = obj2[prop];
}
context.setVariable('mergedResponse', JSON.stringify(obj1));

2. I don't know what you mean by "mesh up"

3. Pagination is a different topic. You can search this community for plenty of information.

4. I don't know what you mean by "PathParam". The Servicecallout accepts a Request element, and within that, a Path element. LMGTFY!