Monday, May 4, 2020

Connecting to external Web-Service(SOAP) from Pega

In today's world, there are n number of usecases where there is a need to get information from external systems via Integration. For example, if you are applying for Loan: as a preliminary step bank would check your credit score based on your Customer ID. This means Bank would pass "Customer ID in the request" and get "Credit Score in the response". We started with a real-time usecase. However to understand the basics of Integration: I suggest beginners to pick a simple example: like Calculator where you pass "two integers in the request" and you get "multiplication result in the response". Below diagram is the visual representation of how request flows from Pega to external system w.r.t Calculator SOAP Service for multiplication operation. .

#1 Using"Connect SOAP wizard" from Pega to generate all the rules for Integration.
     1.1. Connect SOAP wizard and steps

#2 Creation of Data Page to use connect rules generated to get the result

      2.1 Configure Connect-SOAP generated in Step #1 to Data Page
      2.2 Set Request Data Transform to map request
      2.3 Set Response Data Transform to map response

     2.1 Configure Connect-SOAP generated to Data Page
  • Create Data Page: "D_Multiply" in the work class of your application
  • So in this example: Applies To class: "MyOrg-Demo-Work"
  • Application ruleset: "Demo"
  •  In Data Page >> Navigate to Parameters and provide two params: intA, intB
  • Mention the parameters as "Integer", as we would pass integers
  •  In Data page >> Select source as Connect-SOAP. And click on the down-arrow to choose our Connect-SOAP rule generated: In this case, it is "Multiply".
  •  Also look at the Connect-SOAP rule to view the endpoint URL
  • In this example, we would leave it as it is. But do remember about Global Resource Setting to refer to endpoint URL:  Click Here to explore GRS
  • If you are a beginner, I would prefer you to proceed with hardcoded URL. And take a look at GRS once you understand this post completely.

   2.2 Set Request Data Transform to map request 
  • In Data page >> navigate to Request Data Transform >> Enter name Set Multiply Request >> And click on open. It takes you to create the new Data Transform.
  • Class would auto-populate as "MyOrg-Int-Opeations-Calculator"
  • Ruleset: Prefer to give it in same Int ruleset. In this example, am using Application ruleset.
  •  In Request Data Transform, map your request as shown below:
  • Parameters intA, int B would be assigned to integration page automatically in this case.
  • Look at the "XML Stream" rule to understand .MultiplyParameters.intA on L.H.S
  • Look at the "XML Stream" rule to understand .MultiplyParameters.intB on L.H.S

    2.3 Set Response Data Transform to map response
  • From Data Page >> Response Data Transform >> Enter "SetMultiplyResponse" >> and open it. It would open a new Data Transform creation form as below. Enter the details and create.
  • It would open the generic template DT as below: where most of the details are already filled. And add your logic in step #1.2 as below:
  • Create a property "MultiplicationResult" in work class and mapped on left hand side (L.H.S) of step #1.2 as below.
  • Map ".MultiplyParametersResponse.MultiplyResult" on right hand side (R.H.S) of step #1.2 as below. Drop down will take you to the selection. But in detail, if you want to understand, please take a look at "Parse XML" rule.
  • Click Save once done.

#3 Run the Data Page to view the result

    #3.1  Configure the Data Page with holistic view:
  • Parameters are passed to data page
  • Connect-SOAP is configured
  • Request Data Transform is configured
  • Response Data Transform is configured
  • *Note: Select "Pass Parameters" for both Request DT and Response DT

   #3.2 Run the Data Page and View results
  • With the above, data page configuration is done, and we are ready to connect to external SOAP service to get the result.
  • Navigate to Data Page >> Actions menu >> Run   
  • Enter the Request parameters values: In the below example, I have entered 5, 5 in the request 
  • And click on Run
  • In happy path: result property i.e. D_Multiply[intA:5, intB:5].MultiplicationResult = 25


Summary
  • In the previous post, we have seen how we passed request and got response from POSTMAN.
  • Same way, we are able to connect to external SOAP Service to get the multiplication result  to Pega.
  • We passed two integers in the request 5 and 5. And we got the result from SOAP Service as 25.
Some more context:
  • In calculator service, we have taken mulitplication operation as an example. Because everyone knows about this logic. 
  • Ideally in real-world we connect to external systems to get some data like: "For a particular Customer ID=> you would like to fetch Credit Score". If you are familiar with concepts mentioned in this post, you would apply the same concept where: Request= CustomerID, Response=CreditScore.
  • Hope you have followed it. If you have any questions/suggestions, please leave a comment. And I would make sure I reply at the earliest that I can. Thanks.
Stay tuned. We have successfully created Connect-SOAP in Pega to connect to SOAP Service via HTTP endpoint. In the next posts, we would look at how to achieve same usecase to different SOAP Service which has HTTPS endpoint.

Related Posts:

Thanks,
HowToPega.info

5 comments:

  1. Thanks Pavan for such a wonderful article. It really helped me

    ReplyDelete
    Replies
    1. Thanks for the feedback. I am glad it helped you.

      Delete
  2. Hi Pavan If I have to cahne te operation and new fields need to be added then how to update my wsdl or how o get updated wsdl?

    Do I need to run the service wizard again ?

    ReplyDelete
    Replies
    1. When service team updates the WSDL, ideally all the consumers would be notified via some process on the WSDL changes. And a new copy of WSDL would be received by all the clients. In this case, since we are client, we would also receive the WSDL.
      Yes we need to run the "Create SOAP Integration" wizard once again which would incorporate delta changes.
      I would be adding one more post for this one since I have got few more requests on this. Thanks.

      Delete
  3. DO we need to follow only this approach or ay other smart ways

    https://community.pega.com/knowledgebase/articles/data-integration/how-manage-changes-wsdl-and-xsd-metadata-soap-connectors-using-ruleset-versioning

    ReplyDelete


HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu