Assigning a soap header using proxy

Hi All,

I am using a proxy of the web service to connect to the webservice , now i want to assign a soap header to the

request , how can this be done.

Please post any code snippets regarding this.



Suresh Kumar Goudampally 


11/5/2008 10:51:22 AM 7071 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 29

Hi Suresh,

I belive you are using HttpWebRequest to call the web service.

 If that is the case follow the code below.

   private static HttpWebRequest CreateWebRequest(string url, string action)
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
        webRequest.Headers.Add("SOAPAction", action);    // Change the code here to add your custom header.
        webRequest.ContentType = "text/xml;charset=\"utf-8\"";
        webRequest.Accept = "text/xml";
        webRequest.Method = "POST";
        return webRequest;

Hope this helps.

Microsoft Certified Professional Developer - Web Developer
11/5/2008 2:35:57 PM

Hi pradeepy ,

I am not calling the webservice as u mentioned above,

just i am using the proxy of the webservice to call.



Suresh Kumar G




11/5/2008 2:47:42 PM


In that case in your proxy.cs or reference.cs. Add the below lines of code.

I am not sure if there is still a better of way of doing this.

 protected override WebRequest GetWebRequest(Uri uri)
            HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);

              webRequest .Headers.Add ("SOAPAction: " + soapAction) ; // Add your custom soap header here

            return webRequest;

 Hope this helps.

Microsoft Certified Professional Developer - Web Developer
11/5/2008 3:08:50 PM

Hi Suresh Kumar G,

We normally create soap header class  and add attribute to web method. When client add web reference, it will generate soapheader class automatically. We just code like below:

AuthWebService.WebService webService = new AuthWebService.WebService();
    AuthWebService.AuthHeader authentication = new

    authentication.Username = "test";
    authentication.Password = "test";
    webService.AuthHeaderValue = authentication;

You can find a lot of completed samples on the web:


Best regards,
Guang-Ming Bian - MSFT


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
11/11/2008 9:21:39 AM

Similar Artilces:

How do I set a session ID in a web service SOAP header using a .NET proxy?
I have a web service proxy set up in PB 10.5. I need to set a session ID in the SOAP header so the web service can validate subsequent requests for this session. Is this possible? You can't modify the SOAP headers unfortunately. That capability is supposed to be forthcoming in an EBF/Maintenance Release, but I do not now of an specific timeframe. On 20 Apr 2006 13:40:54 -0700, "Libby Engelbret" <> wrote: >I have a web service proxy set up in PB 10.5. I need to set a session ID in >the SOAP header so the web service can val...

web service SOAP Headers
If this isn't the right forum, let me know what is.Is there a difference between SOAP serialization and  and XML serialization.I have been reading heavily and am now quite confused.I understand that SOAP serialization produces XML, but perhaps without a specific schema or a scheme very different from XML. In the context of web services, the XML Serializer is used to produce XML in SOAP format. What you may be getting confused about is that there is also a "runtime serialization" subsystem. This can serialize data either using a Binary Formatter, or a SOAP Formatter. It...

Web Service Proxy is ignorning SOAP:Header
I'm using a custom soap header to return any errors that are generated by sql server calls. In my webserivce call to UpdatePatientPersonal I'm missing a stored procedure parameter so my ExecuteNonQuery is generating a SQLException which I catch. I take the necessary bits of info from this exception and add them to my custom Soapheader object. I've registed the the outputted header using the SoapHeaderAttribute. I added in a tracer to intercept the SOAP messages and to output them to a log file. When I make the call, the logfile shows that the SoapHeader error is in place and that ...

Re: Using XML Web Service in VS.NET
Dear all, I added a "test.asmx" file in my current project and I coded all Web Method in the test.asmx.cs in VS.NET. Now I want to ask how can I call the web methods in other C# Class? Suppose the class name of the asmx is "test". How can I instantiate the object of that class? Regards, Joe someone can correct me on this.... i hav done a walkthrough using XML webservice. I have created a windows application that can call methods from the webservice, with the use of a dataset in the webservice. after "adding a web reference" to my windows appli...

XML Web Service Message from .NET to NonStop SOAP Server
Here's the XML parsing error the NonStop (Tandem) SOAP Server is generating as a result of a Web Service request from my .NET web client.  The web service in question works fine when the XML request comes from the "test" html client.  My question is, is this a lack of carriage returns a problem?  (see trace information below) >> 2008/10/15 14:32:3::Y7H3:<< Unmarshal Error: Invalid input document: Unexpected extra node(s) at the end of the document>> 2008/10/15 14:32:3::Y7H3:<< SoapDocumentHandler::process:Fault occurre...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: Hope this helps....

I want to know how to call a web service without using a proxy and giving xml as input
I want to know how to call a web service without using a proxy and giving xml as input instead of objects.This xml should be automatically serialized into an object at the service...

HTTP protocol violation error using .NET 2.0 web services through Squid-2.5 proxy
Hello,A client of ours using the Squid proxy server (version 2.5.STABLE6-3.4E.12.1) on Red Hat Enterprise Linux 4 is experiencing a problem when running our .NET 2.0 client application, which communicates with a .NET 2.0 web service on our server.When our client application sends an HTTP 1.1 request through the Squid proxy to our server, it receives the error:"The server committed a protocol violation. Section=ResponseStatusLine"Other clients not using Squid are not experiencing this problem.Researching this, we've found a few posts that report similar problems using .NET 2.0 w...

.NET Web Service Proxy (EasySoap vs .NET)
Greetings all, I was provided with a URL for a web service that is password protected. I saved the WSDL file from the browser and am attempting to create a .NET Web Service Proxy to use it. When I select EasySoap for the 'Web Service Selection', I see one service ('Services') and five 'Structures' (which is the number of 'methods' that I am expecting to see). But when I select .NET, I still see one service (named differently) and only one structure. Four of the structures are missing. Is there something else I need to do to view the four ...

cannot create proxy using the web services proxy wizard
I am trying to access a PB component deployed to EAS via web services. I've created the wsdl document and I am able to call this web service from a ..Net client (I've created the proxy classes using to microsoft wsdl), so the web service is working fine. The problems is that when I try to create the proxy in PB the web service proxy wizard say that it is "Unable to process document referenced in "import" element." I've tryed with both wstest.wsdl and wstestImpl.wsdl, I am not sure about what is the right document to use. I've added pbsoapclient90.p...

New to web services, why does PB10 web service proxy wizard say there are no services?
here... oops typo... still doesn't show any services though... "Chance" <> wrote in message news:43b44cb3$1@forums-1-dub... > here... > > > Upgraded to 10.2x and now seems to be least it created the proxy. "Chance" <

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

Consuming a .NET web service in Delphi 2010 using a service reference
Hi, I've been asked to modify one of my existing applications (D2010 Win32) to interact with a web service written under VS2010/.Net 4. The information I have so far is :- "As communication is secured by .NET WsHttpBinding data encrypting, In order to consume it you have to add to your application a Service Reference (not a web reference) that joins the service available at the URL: . Assuming that the binding created in your app.confing is named "WSHttpBinding_ISms" you have to instantiate a client as shown below: {c...

Web resources about - Assigning a soap header using proxy -

South Carolina Legislators Vote to Cut University Funding for Assigning LGBT Books
Republican legislators in South Carolina want to teach two state universities a lesson for assigning books with LGBT themes.

Pitfall of Scrum: Assigning Tasks
Learn more about our Scrum and Agile training sessions on Even though the concept of self-organizing teams has been around ...

Google celebrates Teacher Appreciation Week by assigning new features to Classroom
The first full week of May is designated in the U.S. as Teacher Appreciation Week. It happens to be this week. And in honor of the occasion, ...

Assigning Odds to Every Potential Buccaneers 1st-Round Pick
The NFL draft is the most elaborate gambling enterprise in existence. Obviously, there is considerable skill involved in developing an NFL prospect, ...

Assigning Fault For Impending Democratic Congressional Losses
Last night we took a look at some of the poor schlubbs Steve Israel had recruited to run for Congress and has now abandoned, tainted by his losing ...

Assigning blame for new, more costly medical plan, Corporate points to Washington's favorite piñata
I'm always skeptical when companies make broad statements without citing dollar amounts or other hard numbers to back them up. That's why Corporate's ...

Programatically assigning a Customer Group in Magento
Magento’s Customer Groups give you the ability to offer different pricing and promotions to customers based upon their grouping. This grouping ...

Selfie With Parents’ Sex Toys? Alameda Teacher Accused Of Assigning Bizarre Extra Credit For Sophomores ...
Parents of students at an Alameda high school want a teacher fired after they say he sent them home with an extra credit assignment of finding ...

RG3 confirms progress, avoids assigning blame
In an exclusive interview with Redskins Nation, RG3 discusses his recovery and his desire to move past assigning blame.

Resources last updated: 11/28/2015 11:55:58 AM