none
Merging of Multiple Web service response into single service response.

    Question

  • Hello Community,

    I would like to gather some information for the below mentioned scenario. Any assistance would be appreciative.

    Scenario

    Caller would be requesting to perform a get service operation for different endpoints using the below mentioned schema and would be expecting to get a single response for the request.

    <RootNode>

    <Endpoints>https:// Application1.com.au</Endpoints>

    <Endpoints>https://  Application2.com.au</Endpoints>

    ...

    </RootNode>

    Note: The endpoints are dynamic in Nature which means the user can entry n number of endpoint for validation.

    I am currently using Biztalk orchestration for looping ,constructing single xml request  and sending the request to different system using dynamic send port.

    The Problem: 

    How do I construct a single service XML response from all the service responses received from different system? or Merge all service response into single response and send that back to the caller?

    Thanks in Advance.

    Himanshu.

    Thursday, April 6, 2017 5:08 AM

Answers

  • Hi,

    1) Create a string variable and load the opening tags of the response message before the loop begins, something like

    str="<RespMsg>";


    2) Inside the loop After the service call append the response from the service to this string variable each time the loop executes. Something like

    str=str+ "<Resp1><A>value</A></Resp1>";

    3) After all the service calls are done outside, end the string with the closing tag of the response message, something like

    str= str+ "</RespMsg>";

    4) Make a xmlDocument variable and following code

    msgResp=xdoc.LoadXml(str);

    That will give you your complete response

    Regards


    Mandar Dharmadhikari

    Thursday, April 6, 2017 5:20 AM
    Moderator
  • Hi Himanshu,

    Are all services response in same format ? if yes then every time after getting the response from the service you just need to save the into folder location . 

    In the send port use Append option instead of create new , so everytime it will append the response from each service into a single file . Once your loop will complete then you can read that file by using below code :

    msgResp=xmlDocument.loadXml(full file path);

    and then send to the caller service.


    Regards

    Abhay Giri

    Mark this reply as answered or vote if this help you.

    Thursday, April 20, 2017 5:26 AM

All replies

  • Hi,

    1) Create a string variable and load the opening tags of the response message before the loop begins, something like

    str="<RespMsg>";


    2) Inside the loop After the service call append the response from the service to this string variable each time the loop executes. Something like

    str=str+ "<Resp1><A>value</A></Resp1>";

    3) After all the service calls are done outside, end the string with the closing tag of the response message, something like

    str= str+ "</RespMsg>";

    4) Make a xmlDocument variable and following code

    msgResp=xdoc.LoadXml(str);

    That will give you your complete response

    Regards


    Mandar Dharmadhikari

    Thursday, April 6, 2017 5:20 AM
    Moderator
  • Hi,

    You can implement “Scatter and Gather” Design Pattern in Orchestration to sent messages to multiple recipients. And use “Aggregator” Design Pattern to consolidating response into a single message.

    https://msdn.microsoft.com/en-us/library/ee236758(v=bts.10).aspx

    https://msdn.microsoft.com/en-us/library/aa561747.aspx

    Regards,

    Surendra


    Thursday, April 6, 2017 5:34 AM
  • HI HimanshuPatro,

    Any update on the issue?


    Mandar Dharmadhikari

    Wednesday, April 19, 2017 7:47 AM
    Moderator
  • Hi Himanshu,

    Are all services response in same format ? if yes then every time after getting the response from the service you just need to save the into folder location . 

    In the send port use Append option instead of create new , so everytime it will append the response from each service into a single file . Once your loop will complete then you can read that file by using below code :

    msgResp=xmlDocument.loadXml(full file path);

    and then send to the caller service.


    Regards

    Abhay Giri

    Mark this reply as answered or vote if this help you.

    Thursday, April 20, 2017 5:26 AM
  • Hello Mandar,

    The above mentioned approach is promising but I need to perform multiple operations on each response  before the step such as calculating the duration on each response and appending the logs of each calls.

    str=str+ "<Resp1><A>value</A></Resp1>";"

    Any idea on how to capture the service logs? These verification logs needs to constructed on top of the response message received from each party.

    <VerificationLog>
    <LogEntry>Service has been invoked. Verifying version.</LogEntry>
    <LogEntry>Service is correct version.</LogEntry>
    </VerificationLog>

    Regards,

    HP

    Saturday, April 22, 2017 5:43 AM
  • Can you not use a map in an orchestration to combine all of the responses into one message?  You can do whatever operations on the data that you need to before mapping them together.
    Wednesday, April 26, 2017 4:38 PM