Link to home
Start Free TrialLog in
Avatar of oidualc61
oidualc61Flag for Switzerland

asked on

Create EndpointAddress with Header

Hi

I try to create to following Endpoint in my c# code:

<endpoint address="http://someurl/soap/index.php" binding="basicHttpBinding"
  bindingConfiguration="b2bwsdlBinding" contract="something.b2bwsdlPortType"
name="b2bwsdlPort">
<headers>
   
 <UsernameToken>
  <password>xyz</password>
  <username>test</username>
  <b2bpartnerId>111</b2bpartnerId>
</UsernameToken>
</headers>
</endpoint>

=============


i tried this:



List<AddressHeader> addressHeaders = new List<AddressHeader>();
AddressHeader addressHeader1 = AddressHeader.CreateAddressHeader("UsernameToken","", "123");
addressHeaders.Add(addressHeader1);
  EndpointAddress endpointAdress = new EndpointAddress(new Uri("http://www.someurl.com/soap/index.php") , addressHeaders.ToArray());

But the Problem is, i cant build the hole XML hierarchy in the header. I just have to possiblitiy to create one xml child:

<s:Header>
<UsernameToken>
123
</UsernameToken>
</s:Header>



Can anybody help me?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of spprivate
spprivate
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oidualc61

ASKER

Thanks for your answer. But this example show only how to create simple header without any further child. I need a Header Like this:

<headers>
 <UsernameToken>
  <password>xyz</password>
  <username>test</username>
  <b2bpartnerId>111</b2bpartnerId>
</UsernameToken>
</headers>
</endpoint>

As you see the header Usernametoken does have 3 childs.