In this post we will see how to setup UsernameToken in webMethods webservice consumer connector. We will be covering only username/password based WS-Security. There are other ways also to secure consumer like signature, encryption using certificates. Username Token is a standard WS-Security feature which is not associated in webservice consumer by default until and unless dictated by WSDL. Below is one example of soapHeaders with UsernameToken.
In cases where WSDL doesn’t mention anything about WS-Security then there are two ways to generate UsernameToken at soapheader level. In this post we will look at one of the methods. This method uses webMethod’s Pre 8.2 compatibility feature of webservice connectors. WebServices developer guide is not very clear on how to generate UsernameToken tags. It just says set values for auth/message/user and auth/message/pass fields and the UsernameToken will be generated. However, they forget to add the steps / procedures to be followed to generate the UsernameToken. Let’s get to work…enough of blabbering.
- Open web service consumer connector for which you want to generate UsernameToken.
- Lock For Edit and go to properties window of consumer.
- Check if Pre-8.2 compatibility mode is set to “true”. If not then change it to true. Screen shot below.
- Save consumer and Now go to Handler Tab.
- Right Click in Handler Tab. Select “Add Handler” Option.
- A dialogue box as shown below will appear. Select WS Security Handler and click OK.
- Select the Handler added in previous section. Once highlighted property window will have option like shown below.
- Select policy “Consumer policy for Username” and save consumer.
- Next part is to use connector in Flow service.
- Invoke connector in flow service and set auth/message/user and auth/message/pass variables for username and password respectively.
Once you have completed the above mentioned steps, soapHeaders will have UsernameToken tag. You can use TCPIp monitor or some other kind of tool to capture soapHeaders. It is pretty simple and easy to implement. Please do let me know your feedback in comments section.
Questions? Comments? Suggestions? Let us know!! Like / Subscribe / Follow for more updates.