XML Web Service Soap headers

J

Jawahar

I am in the process of setting up a XML web service as follows. I am trying
to find a way to pass the SOAP header from the client?
I have seen many example but they do not seem to work for me.
There are two ways it seems
Using proxy class or
just using an instance of the AuthenticatioHeader class in the Client app.
But how can the client app recognise the Public class that defines the soap
headers?

I have a public Class in WebService project
public class AuthenticationHeader : System.Web.Services.Protocols.SoapHeader
{
public string UserName;
public string Password;
}

then I have my Web Method in the web service class
[WebService(Namespace="http://example.com/webservices/stockquotes")]
public class QuoteService : WebService
{
[WebMethod()]
[SoapHeader("AuthHeader",Direction=SoapHeaderDirection.In)]
public decimal GetQuote(string ticker)
{
CheckAuthorized(); //this is a check to check the UserID and PWD
QuoteEngine quoteEngine = new QuoteEngine();
return quoteEngine.GetStockPrice(ticker);
}
}

in the client app I have:
private decimal GetQuote(string username, string password, string ticker)
{

StockQuote.QuoteService ws = new StockQuote.QuoteService();
return ws.GetQuote(ticker);
}

I realize that this is a very classic example found all over the place.
But I am still in doubt as to how to pass in the SOAP headers it self.
Can I simply say localhost.webService proxy = new localhost.webService()
Then use the public AuthenticationHeader class
or how can i get an instance of the AuthenticationHeader public class? in
the client application.
Is this possible?

Any help or suggestions are always appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top