Situation: We has a situation where we invoke a single Rest URL externally with different client Id as shown below:-
1. http://myservicesite.net:8080/adeptia/api/ws/client/*123*/check?cod=125gcv
2. http://myservicesite.net:8080/adeptia/api/ws/client/*763*/check?cod=1gd23
3. http://myservicesite.net:8080/adeptia/api/ws/client/*9453*/check?cod=1dfghj
4. http://myservicesite.net:8080/adeptia/api/ws/client/*19723*/check?cod=3456y7u8
Here, you can see a parameter(clientId) embedded into the URL with different values (123, 763, 9453, 19723) after that, there is a parameter named cod* (but it could be other param/s)*
When my WebService Provider receives the URL (1 - 4), it has to call a Rest WS Consumer with the following URL and PARAMETERS (A - D)
A. http://another_website.net:9090/adeptia/api/ws/client/*123*/check?cod=125gcv
B. http://another_website.net:9090/adeptia/api/ws/client/*763*/check?cod=1gd23
C. http://another_website.net:9090/adeptia/api/ws/client/*9453*/check?cod=1dfghj
D. http://another_website.net:9090/adeptia/api/ws/client/*19723*/check?cod=3456y7u8
Solution: You can do so by defining the parameter name(clientId) within curly brackets "{ }" as {clientId} in Rest WS Provider URL. Following are the steps to achieve this requirement:-
1. Simply create a Rest WS Provider and define the Url as "/client/{clientId}/check" along with other parameters "cod". Here, clientId is a variable whose value is dynamic and can be accessed as $$clientId$$ in the context variable.
2. Create a web consumer and provide rest URL like dummy or any URL that you want to define.
3. In the process flow designer,
For Invoke URL "http://myservicesite.net:8081/adeptia/api/ws/client/*123*/check?cod=125gcv", if WS Consumer call URL "http://another_website.net:9090/adeptia/api/ws/client/*123*/check?cod=125gcv"
then you can simply override the WS Consumer restUrl by using the putContext var shown in the following screenshot and connect it to WS Consumer activity. In putContext var, select the web consumer activity name and method "restUrl" and define the value as below:-
http://another_website.net:9090/adeptia/api/ws/client/$$clientId$$/check?cod=$$cod$$
So, the Process flow contains the following activities:-
a. putContext var
b. Ws Consumer
c. Context Target
Note: In case, if the calling URL pattern is not fixed i.e. if Ws Consumer calling URL is different for every invoked URL, then you need to create a Custom Plugin to handle this and save that Url in a variable and pass this variable in a putContext var (restUrl) to override the URL present in WS Consumer.
So, in this case, the Process flow contains the following activities:-
a. Custom Plugin
b. Ws Consumer
c. Context Target
You can also refer to the below-attached Process flow.
Comments
0 comments
Article is closed for comments.