Search code examples
.netsamlsoapheaderoperationcontext

Can I use OperationContextScope in any .NET client?


I am exploring around injecting soap headers into out going message while calling java based service from .NET client.

I see that OperationContextScope is best fit for my requirement as shown below and which works fine in initial test. I wanted to make sure i am not doing any blunders with this as my application is .NET console batch. will it be there any issues using this class in context of .NET console application?

I created a proxy for JAVA service using SVCUITIL by passing wsdl & xsd.

using (var client = new GetXXXXDetailsServiceClient())
                    {
                        using (new OperationContextScope(client.InnerChannel))
                        {
                            var customerHeader = new Headers(SamlAssertion.InnerXml.ToString());
                            OperationContext.Current.OutgoingMessageHeaders.Add(customerHeader);
                            var res = client.GetXXXXDetails();

                        }
                    }

Solution

  • seems we can use anywhere this OperationContextScope as my app running fine in DEV env.