2

I have some code on my C# webservice, that checks the header string contains a valid user.

The code is:

MessageHeaders headers = OperationContext.Current.IncomingMessageHeaders;
String soapHeader = headers.GetHeader<String>("VerifyUser", "http://companyname.co.uk");

Where soapHeader is the string I check. (currently contains username and password(MD5))

How would I send a string from SAVON Rails in the header, so that it can be pulled back off on the webservice.

Preferably without changing the current C# code, unless you can specify a way of sending from a C# client as well.

Ive tried

response = client.request :wsdl, :get_customer_centre_details do
  soap.header = { "VerifyUser" => "1:5F4DCC3B5AA765D61D8327DEB882CF99" }
end

Cheers!

EDIT: This is how I currently add the header in C#

OperationContextScope scope = new OperationContextScope(ConChannel);
MessageHeader<String> header = new MessageHeader<String>(UserID + ":" + md5HashString);
var untyped = header.GetUntypedHeader("VerifyUser", "http://www.companyname.co.uk");
OperationContext.Current.OutgoingMessageHeaders.Add(untyped);
IAmGroot
  • 13,760
  • 18
  • 84
  • 154

1 Answers1

2

What I was missing was the attributes option, to add on the XML namespace, hence it was not being identified as the same header.

    response = client.request :wsdl, :get_services do
      soap.header = { "VerifyUser"  => "1:5F4DCC3B5AA765D61D8327DEB882CF99", :attributes! => { "VerifyUser" => { "xmlns" => "http://www.companyname.co.uk"} } }
    end
IAmGroot
  • 13,760
  • 18
  • 84
  • 154