Overview
In real-life projects, we frequently encounter scenarios where we need to interact with external partners via REST APIs. In such cases, we often store the endpoint and its credentials either in a configuration file or within webMethods’ internal storage using pub.storage utilities. We can securely store the endpoint and the credential in MWS and we can retrieve and use it in our flow services even if we are not using the B2B component. We can also store the contact details of whom the support team can contact in case there is a change in credentials. We will go through the step-by-step process involved in storing and retrieving it from MWS.
Prerequisite :
- MWS should be installed and in a running state, if MWS is not installed in your system then click here to check out the process involved.
- The webMethods integration server should be connected to MWS.
- Basic understanding of webMethods flow service.
Create Partner profile in MWS :
- Log in to My webMethods Server.
- If your MWS instance is connected to multiple integration server instances then select the target server using the drop-down list available in the top right corner of the MWS.
- Navigate to the Partner profile using Administration/Integration/B2B/Partner Administration/Partner Profiles and click on Add Profile to onboard a new partner.
- Configure the below properties to onboard new Partner.
- Partner Details :
- Status: Make it Active.
- External ID :
- Navigate to the External ID tab and click on Add ID.
- Contacts :
- Navigate to the Contacts tab and then click on the Add Contact button to configure the contact details of the partner.
- Delivery Settings :
- Navigate to the Delivery setting and click on Add Delivery Method.
- Select the delivery method from the drop-down such as http/https/smtp/SFTP.
- Fill in the host and port along with the user ID and password and click ok.
- Partner Details :
- Once you fill in all the details, click Save & Close button to save the configuration.
Create Util service to extract URL and Credential :
We have the duns number with us which we have provided while creating the partner profile so we will utilize that to extract the partner ID which is created and assigned once the partner is onboarded in MWS. We will again query to get delivery details using the partner ID.
- Create a package with the name ‘HG_Util‘ and follow below package structure.
- HG_Util
- util
- HG_Util
- Create a service inside the util folder with the name get partnerDetails and create an input variable with the name ‘dunsNumber‘ of type string, additionally create three output variables of type string with name url,userId,password.
- Invoke the ‘wm.tn.profile:getInternalID‘ service and follow the below mapping.
- dunsNumber ->id.
- idTypeDesc -> Hardcode it with DUNS.
- Drop unnecessary variables.
- Invoke ‘wm.tn.profile:getProfile‘ to get the profile details and map partnerID to partnerID.
- Invoke map step and hard code URL with ‘%profile/Delivery[0]/Protocol%://%profile/Delivery[0]/Host%:%profile/Delivery[0]/Port%%profile/Delivery[0]/Location%‘ and check variable substitute option, additionally follow below mapping to extract userid and password.
- userId->profile/Delivery[0]/UserName.
- password->profile/Delivery[0]/Password.
- Drop all unnecessary variables.
- Now run the service and provide the duns number that you have assigned while creating the profile and you will see URL,userid and password in the output.
Download source code from Git Hub.
Hope you have enjoyed this article, Cheers!