Soap Header

Discussion in 'ASP .Net Web Services' started by mmorrison93@yahoo.com, Sep 9, 2005.

  1. Guest

    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
     
    , Sep 9, 2005
    #1
    1. Advertising

  2. Brock Allen Guest

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

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
    >
     
    Brock Allen, Sep 10, 2005
    #2
    1. Advertising

  3. Guest

    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
     
    , Sep 12, 2005
    #3
  4. Brock Allen Guest

    It's a header you'd add in yourself in your WSDL. On the server side you'd
    use [SoapAttribute] as doc'd here:

    http://msdn.microsoft.com/library/d...cesprotocolssoapheaderattributeclasstopic.asp

    The if you're using .NET for the client side proxy generation, it's created
    as a property on the proxy class.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > 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
    >
     
    Brock Allen, Sep 12, 2005
    #4
  5. Guest

    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
     
    , Sep 14, 2005
    #5
  6. Guest

    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...
     
    , Sep 17, 2005
    #6
  7. Brock Allen Guest

    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.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > 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
    >
     
    Brock Allen, Sep 19, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sham Ramakrishnan
    Replies:
    2
    Views:
    8,479
    Sham Ramakrishnan
    Jul 1, 2003
  2. mooseshoes

    To SOAP or Not To SOAP?

    mooseshoes, Sep 4, 2003, in forum: XML
    Replies:
    3
    Views:
    430
    Heinz Häberle
    Sep 21, 2003
  3. Nagesh
    Replies:
    2
    Views:
    9,515
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Aug 12, 2006
  4. mlt
    Replies:
    2
    Views:
    914
    Jean-Marc Bourguet
    Jan 31, 2009
  5. Peter van der veen

    How to add SOAP header to a SOAP message?

    Peter van der veen, Nov 8, 2006, in forum: ASP .Net Web Services
    Replies:
    6
    Views:
    645
    J. Dudgeon
    Nov 14, 2006
Loading...

Share This Page