One environment and 2 different target endpoints for the same api proxy end point

In our case, there is only one environment for one organization

like:

org : company

env : common,

but our cloud foundry has 2 spaces where there are 2 instances of a service for example,

target endpoint url : http://applicationservice-localqa.company.com ( deployed in cf space 'localqa')

target endpoint url : http://applicationservice-autoqa.company.com ( deployed in cf space 'autoqa')

can I configure for one environment for one organization these 2 different target endpoint urls for same proxy endpoint?

Now, since I have only one 'common' environment for my organization 'company' , I have created a proxy endpoint like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="drugsservice">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <Flows/>
    <HTTPProxyConnection>
        <BasePath>/drugcompany/v1/drugs</BasePath>
        <Properties/>
        <VirtualHost>default</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="drugsservice">
        <TargetEndpoint>drugsservice</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

Now for the target endpoints I have 2

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="submissionservice">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <Flows/>
    <HTTPTargetConnection>
        <Properties/>
        <URL>http://drugservice.localqa.company.net/api/v1/drugs</URL> 
 -----> <URL>http://drugservice.autoqa.company.net/api/v1/drugs</URL>
( can this be possible)
    </HTTPTargetConnection>
</TargetEndpoint>

can this be possible?

Looking forward for some help.

Thanks in advance

Aditya Chava

0 5 434
5 REPLIES 5

You'll need to define two different endpoints (eg: submissionservice_local, submissionservice_auto) and then use conditional routing based on something (eg: a header in the request) to decide to which target endpoint to send the request to.

Not applicable

No, you cannot specify the two urls like that.

You need to create two target endpoints and in proxy endpoint need to route the traffic on the basis of condition in the route rule.

You can also set the target url using javascript putting with condition in the target endpoint preflow request.

If there is no condition and you want to just send the traffic to both, then can have two load balancer variables in the target endpoint.

I have one target end point which returns 10 XML fields in proxy output. I have created two proxies which hit same target end point.
For first proxy I want to return first 5 fields and second one should return remaining 5.

Do I need to add XSLT in each proxy to achieve this outcome ? Multiple proxies with single target endpoint

you can have 2 different conditional flows and in the response of each flow you can set your response using extract variable and assign message.

you can also have two separate proxies.

you can also have one proxy with two proxy endpoints and one target endpoint

I normally use extract variable and assign message for these.

You can define two or more "routerule" and based on condition you can call required one.