473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Add an element to the soap header in C#.Net

I'm using webservices written in java from a C#.net application. For this I have referenced the Microsoft.Web.Services3 dll.

I have added the username token to this using the below code.
Expand|Select|Wrap|Line Numbers
  1.  NewClass.NewClassServiceWse ws = new NewClass.NewClassServicewse();
  2. Microsoft.Web.Services3.Security.Tokens.UsernameToken UToken = new Microsoft.Web.Services3.Security.Tokens.UsernameToken(UserName, UserPwd, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendHashed);
  3.   ws.RequestSoapContext.Security.Tokens.Add(UToken);
  4.  
The Soap XML generated from this looks like below. I want be able to add a new attribute to this soap header like <wsx:CustomElement><wsxx:CustomAttr>true</wsxx:CustomAttr></wsx:CustomElement> in between any of the elements. How can I do it?

Expand|Select|Wrap|Line Numbers
  1. <soap:Header>
  2. <wsa:Action></wsa:Action>
  3. <wsa:MessageID>urn:uuid:b5cff8b4-39af-494d-b336-efa760c1111e</wsa:MessageID>
  4. <wsa:ReplyTo><wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
  5. </wsa:ReplyTo>
  6. <wsa:To>http://www.noname.com/ws/services/NewClass</wsa:To>
  7. <wsse:Security>
  8. <wsu:Timestamp wsu:Id="Timestamp-938121ed-e804-4362-a66d-a8d382228e">
  9. <wsu:Created>2009-08-19T18:14:37Z</wsu:Created>
  10. <wsu:Expires>2009-08-19T18:19:37Z</wsu:Expires>
  11. </wsu:Timestamp>
  12. <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="10">
  13. <wsse:Username>username</wsse:Username>
  14. <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">dtuy+oL6GT7872tuVTxRqWKTWbw=</wsse:Password>
  15. <wsse:Nonce>NVJZqbCS07u67mn6wTPUqw==</wsse:Nonce>
  16. <wsu:Created>2009-08-19T18:14:37Z</wsu:Created>
  17. </wsse:UsernameToken>
  18. </wsse:Security>
  19. </soap:Header>
  20.  
Aug 20 '09 #1
0 2508

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Erik | last post by:
Hi I'm writing a schema for a particular soap message. In the soap schema any content is allowed in the header and body elements. Is it possible to define the elements allowed in the header and...
0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
0
by: Frederico Guimar?es via DotNetMonster.com | last post by:
Hi, I'm trying to use the Microsoft.Web.Services2.Messaging. ISoapFormatter but I receive this error: System.Xml.XmlException: The root element is missing. at System.Xml.XmlTextReader.Read()...
0
by: Daniel Thune, MCSE | last post by:
I am having a problem with formatting a SOAP Header in a .Net client. The client calls a Java Axis 1.1 based web service. In order to authenticate the caller, the web service call is intercepted by...
0
by: Kaush | last post by:
Hi all, I am implementing a web service server to accept SOAP messages from my client and send a SOAP response back. Actually I am using .NET's WSE-2 for receiving and sending SOAP messages. The...
0
by: | last post by:
i just read through Axis user doc, but all sample app it mention doesn't show how to use the <HEADER> tag inside soap request / response. 1 -- is <HEADER> tag not much a use when doing 1 - 1 host...
5
by: vthakur | last post by:
Hello: I have a Axis Web Service that sets the sessionid in the SOAP header for persisting the session. The client is a .Net client that processes the header as an Unknown Header. It sets the...
3
by: jparulan | last post by:
Hi All, I'm using SOAP3.0. I was able to successfully call a WSDL file and get a value properly. But when the WSDL changed to have a MULTIPLE <element name> it was failing. This code works...
0
by: vigneshrao | last post by:
Hi, I have been working on a script that loops through multiple records and sends data (one record per call) to a WS. I am supposed to make a new call for each record before sending the data....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.