Soap Header

M

mmorrison93

I have a question about adding a soap header to a soap request. I'm
currently trying to consume a web service that requires that I place
authorization information in the header. The proxy class that I am
working with inherits the
System.Web.Services.Protocols.SoapHttpClientProtocol class. Is there
any function that I can call from this class, that will allow me to
create the header I need. For example, if I need to put the following
line into a header <authorizationID>123456</authorizationID> is there
any function call in the System.Web.Services.Protocols namespace that
will allow me to add this? There are no user defined methods in the
proxy class to acheive this.

Thanks in advance for you help.

Michael Morrison
 
B

Brock Allen

If you're using a .NET WS proxy then the proxy class should have a property
where you can set the header.
 
M

mmorrison93

Thanks Brock, Do you know what property or function I'd call in order
to add this header? I've looked at the documention on Microsoft's site
on the class methods and properties in the SoapHttpClientProtocol
class, but I'm still not sure which of those will allow me to add the
header.

Thank you again.

Michael Morrison
 
M

mmorrison93

Thanks again Brock, I'm still a little bit confused though, I know my
soap header should appear in the following format:

<SOAP:Header>
<smSessionID>1234567890</smSessionID>
</SOAP:Header>


what i've done in is declared a class called "smHeader" in the same
file as my proxy class (the proxy class is called webserviceService),
this class looks like this:

Public Class smHeader
Inherits SoapHeader

Public smSessionID As String

End Class

in the proxy class, I declare an instance of the smHeader class like
this:

Dim Public smAuthenticate as New smHeader

then for the function call (smquerysystemtime) for which i'd like to
send the soap header I have it declared like this in the proxy class:

<System.Web.Services.Protocols.SoapRpcMethodAttribute("",
RequestNamespace:="http://smapi",
ResponseNamespace:="http://smapi"),SoapHeader("smAuthenticate")> _
Public Function querySystemTime() As
<System.Xml.Serialization.SoapElementAttribute("querySystemTimeReturn")>
smdtTimestamp
Dim results() As Object = Me.Invoke("querySystemTime", New
Object(-1) {})
Return CType(results(0),smdtTimestamp)
End Function

in my .aspx file i declare an instance of the proxy class with the
following:

Dim obj As New webserviceService

then I set the session ID and call the web method querySystemTime()
with these lines :

obj.smAuthenticate.smSessionID = "1234567890"
obj.querySystemTime()
From my understanding this will give me the following soap header:

<soap:header>
<smauthenticate>
<smSessionID>123456</smSessionID>
</smauthenticate>
</soap:header>

how do I get the header that I listed at the top of this message? Also
is there a way for me to see the physical soap envelope, so I can see
exactly what is being sent?

Thanks again for your help.

Michael
 
S

saumya.dasari

Hi,

I do have the same problem in passing the soap headers.
Actually my .net application is consuming a third party webservice which requires authentication info to access the web service. The web service is expecting login and password to be present in the soap headers. There is no separate function to authenticate in the proxy class generated. Just I need to send the soap header. Can I get a help on this pls

Thanks in advance

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
B

Brock Allen

Sorry, I was away for like 2 weeks... just getting back into the routine
now :)

So the soap header should be autogenerated on the proxy from the WSDL file
if you're using the WSDL.exe tool or doing "Add Web Reference" in VS.NET.
So you don't/shouldn't need to add it manually.
 

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,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top