Getting Session Id from SOAP Headerhttp://forums.asp.net/t/1226130.aspx/1?Getting+Session+Id+from+SOAP+HeaderMon, 30 Apr 2012 12:46:06 -040012261302200602http://forums.asp.net/p/1226130/2200602.aspx/1?Getting+Session+Id+from+SOAP+HeaderGetting Session Id from SOAP Header <p>hi,</p> <p>i am calling web service which is created in JAVA. i have it's web reference in my web service(which is in .NET). i am calling it's web method, i am getting string value from web method, but i want to retrieve session ID&nbsp; from the SOAP Header, as that third party web service passing session id in SOAP Header. can anyone give me code for retrieving&nbsp; info from&nbsp; SOAP&nbsp; header. <br> </p> 2008-02-28T05:26:27-05:002213321http://forums.asp.net/p/1226130/2213321.aspx/1?Re+Getting+Session+Id+from+SOAP+HeaderRe: Getting Session Id from SOAP Header <p>Hi query4u,</p> <p>Firstly, you can check proxy class which generate automatically whether it has related class derived from soapheader , if not please new a class derived from soapheader. This will help you get soapheader information. Then you code lie below:</p> <font size="2">localhost.</font><font color="#008080" size="2">Service</font><font size="2"> a = </font><font color="#0000ff" size="2">new</font><font size="2"> TestWebService.localhost.</font><font color="#008080" size="2">Service</font><font size="2">();</font><font size="2"> <p>localhost.</font><font color="#008080" size="2">MySoapHeader</font><font size="2"> MySH = </font><font color="#0000ff" size="2">new</font><font size="2"> TestWebService.localhost.</font><font color="#008080" size="2">MySoapHeader</font><font size="2">();</p> MySH.Username = </font><font color="#800000" size="2">&quot;&quot;</font><font size="2">;</font><font size="2"> <p>&nbsp;</p> <p>a.MySoapHeaderValue = MySH;</p> <p>a.HelloWorld();</p> <p>String m_ExactName=a.MySoapHeaderValue.Username </p> <p>The m_ExactName variable will get the name from soapheader.</p> <p>&nbsp;</p> <p>Secondly, if the first solution doesn't meet your requirement, you get also use SoapExtension to get the whole soap message , then parse the xml to get exact information.<br> For more information:<br> <a href="http://msdn2.microsoft.com/en-us/library/aa719864.aspx">http://msdn2.microsoft.com/en-us/library/aa719864.aspx</a><br> <a href="http://keithelder.net/blog/archive/2007/01/09/Take-Securing-Web-Services-With-Username-and-Password-One-Step.aspx">http://keithelder.net/blog/archive/2007/01/09/Take-Securing-Web-Services-With-Username-and-Password-One-Step.aspx</a></p> <p>Best regards,<br> Guang-Ming Bian - MSFT</p> </font> 2008-03-05T09:54:59-05:002215563http://forums.asp.net/p/1226130/2215563.aspx/1?Re+Getting+Session+Id+from+SOAP+HeaderRe: Getting Session Id from SOAP Header <p>&nbsp;Thanx Guang-Ming Bian for helping me. i will try it.<br> </p> 2008-03-06T05:40:47-05:004958231http://forums.asp.net/p/1226130/4958231.aspx/1?Re+Getting+Session+Id+from+SOAP+HeaderRe: Getting Session Id from SOAP Header <p>Hi,</p> <p>I know this post is so old.. I have a similar scenario now</p> <p>I am consuimg a webservice developed in Seibel , so for the security enhancement, I need to pass the username and password and the connection type and the response will be a sessionID within the header. Please find a sample.. So how can i retrieve this sessionToken from SOAP header?</p> <p>Request</p> <p>&lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;<br> &nbsp; &lt;soap:Header&gt;<br> &nbsp; &nbsp; &lt;Header1 xmlns=&quot;http://siebel.com/webservices&quot;&gt;<br> &nbsp; &nbsp; &nbsp;&nbsp;<strong>&lt;UsernameToken&gt;midhun.sunny@metrosystems.net&lt;/UsernameToken&gt;</strong><br> <strong>&nbsp; &nbsp; &nbsp; &lt;PasswordText&gt;world.1234&lt;/PasswordText&gt;</strong><br> <strong>&nbsp; &nbsp; &nbsp; &lt;SessionType&gt;Stateless&lt;/SessionType&gt;</strong><br> &nbsp; &nbsp; &lt;/Header1&gt;<br> &nbsp; &lt;/soap:Header&gt;<br> &nbsp; &lt;soap:Body&gt;<br> &nbsp; &nbsp; &lt;MG_spcPicking_spcParameter_spcExport_spcV02_spcW_Input xmlns=&quot;http://siebel.com/CustomUI&quot; /&gt;<br> &nbsp; &lt;/soap:Body&gt;<br> &lt;/soap:Envelope&gt;</p> <p>Response</p> <p><span>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;</span><br> <span>&nbsp; &nbsp;&lt;SOAP-ENV:Header&gt;</span><br> <span>&nbsp; &nbsp; &nbsp; &lt;siebel-header:SessionToken xmlns:siebel-header=&quot;http://siebel.com/webservices&quot;&gt;</span><strong>NMJ5kb4xLYKa5OpdbQ61Wrc8nblpEXQ6DprcI50GTKo8keNDX-BxOKJOlfuB3.zcuOs1znmT36iye9ynPr1a8enSrjgzkN12nI9fPlzJNXrO9fnN.nEMYVZj74pCWzdcC9Z-fqZyZ.HLdcrrCU-kLlO0K1LpkN01eXjnFMplwdsHZBKEouqHaUdgkqaZKAd7E0vlD86ClOzDV9zJnFrYxvcfPko0epl1N3Iipa4RLPwNEqg4eAaUPvKBj69F18U8Xl-kHjkVHoZrJjeyYbhtR6bMUaf53eHY</strong><span>&lt;/siebel-header:SessionToken&gt;</span><br> <span>&nbsp; &nbsp;&lt;/SOAP-ENV:Header&gt;</span><br> <span>&nbsp; &nbsp;&lt;SOAP-ENV:Body&gt;</span></p> <p>----</p> <p>&lt;soap:Body&gt;<br> &nbsp; &nbsp; &lt;MG_spcPicking_spcParameter_spcExport_spcV02_spcW_Input xmlns=&quot;http://siebel.com/CustomUI&quot; /&gt;<br> &nbsp; &lt;/soap:Body&gt;<br> &lt;/soap:Envelope&gt;</p> <p></p> <p>Please help..</p> 2012-04-30T12:46:06-04:00