Question

I'm connecting to a RemObjects SDK SOAP server written in Delphi using a C# client. I can make the initial login, but subsequent requests require a custom SOAP header that looks like this:

  <SOAP-ENV:Header SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:MyAPI">
    <NS1:ROClientIDHeader xsi:type="NS1:ROClientIDHeader">
      <ID xsi:type="xsd:string">{3EC5A9DF-C6DC-4BFB-8134-37DDCF07910D}</ID>
    </NS1:ROClientIDHeader>
  </SOAP-ENV:Header>

My existing code looks like this:

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Create a new instance of the login service
            MyLibrary.LoginServiceClient LoginClient = new MyLibrary.LoginServiceClient();

            // Call the Login method on the server
            MyLibrary.TLoginInfo LoginInfo = LoginClient.Login("Administrator", "master", 0, 0, MyLibrary.TClientType.ctWindowsClient);

            // Set the Session ID
            var SessionID = LoginInfo.SessionId;

            // Create a new instance of the Utils service
            MyLibrary.UtilsClient UtilsClient = new MyLibrary.UtilsClient();

            // Set the SOAP header //
            //  <SOAP-ENV:Header SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:EasyIPv6API">
            //    <NS1:ROClientIDHeader xsi:type="NS1:ROClientIDHeader">
            //      <ID xsi:type="xsd:string">{3EC5A9DF-C6DC-4BFB-8134-37DDCF07910D}</ID>
            //    </NS1:ROClientIDHeader>
            //  </SOAP-ENV:Header>

            // Make the call
            var AddResult = UtilsClient.AddValues(1, 1);
        }
    }
}

How do I add the custom header to the request? Please bear in mind that I am currently completely ignorant of C#.

Was it helpful?

Solution

With help from RemObjects we finally got this working. If anyone is interested, they have produced an article explaining how it is done. You can find it http://wiki.remobjects.com/wiki/WIP:Consuming_RemObjects_SOAP_services_with_third_party_clients

OTHER TIPS

If subsequent request expect a Soap Header then the UtilsClient should have a property exposed like SoapHeaderValue which you can set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top