'How to attach Security Token(saml) to Soap request in C# Connected Services

I have 2 connected services (WSDL) in Visual Studio project.

One of those services is used to get a Security Token with a SOAP request. Then part of this response object needs to be attached in the second service request SOAP header. I can't figure out a way to attach the security token in the request header of the second service.

var securityToken = new SecurityTokenService().Issue("securityTokenRequest"); //service 1

securityToken is an xml :

 <saml:Assertion ID ...>
 ///...
</saml:Assertion>

This security token now needs to be attached in the following soap request header.

var operationService = new OperationService.PortClient("operationService"); //service 2

operationService.Operate();

I have followed up this article. But still not clear to me how to attach saml:Assertion into soap header of the second service.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source