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 from the SOAP Header, as that third
party web service passing session id in SOAP Header. can anyone give me code for retrieving info from SOAP header.
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:
localhost.Service a =
new TestWebService.localhost.Service();
localhost.
MySoapHeader MySH =
new TestWebService.localhost.MySoapHeader();
MySH.Username = "";
a.MySoapHeaderValue = MySH;
a.HelloWorld();
String m_ExactName=a.MySoapHeaderValue.Username
The m_ExactName variable will get the name from soapheader.
I know this post is so old.. I have a similar scenario now
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?
query4u
Member
6 Points
45 Posts
Getting Session Id from SOAP Header
Feb 28, 2008 05:26 AM|LINK
hi,
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 from the SOAP Header, as that third party web service passing session id in SOAP Header. can anyone give me code for retrieving info from SOAP header.
Guang-Ming B...
Star
9049 Points
654 Posts
Re: Getting Session Id from SOAP Header
Mar 05, 2008 09:54 AM|LINK
Hi query4u,
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:
localhost.Service a = new TestWebService.localhost.Service();localhost.
MySoapHeader MySH = new TestWebService.localhost.MySoapHeader(); MySH.Username = "";a.MySoapHeaderValue = MySH;
a.HelloWorld();
String m_ExactName=a.MySoapHeaderValue.Username
The m_ExactName variable will get the name from soapheader.
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.
For more information:
http://msdn2.microsoft.com/en-us/library/aa719864.aspx
http://keithelder.net/blog/archive/2007/01/09/Take-Securing-Web-Services-With-Username-and-Password-One-Step.aspx
Best regards,
Guang-Ming Bian - MSFT
query4u
Member
6 Points
45 Posts
Re: Getting Session Id from SOAP Header
Mar 06, 2008 05:40 AM|LINK
Thanx Guang-Ming Bian for helping me. i will try it.
midhun.sunny
Member
2 Points
24 Posts
Re: Getting Session Id from SOAP Header
Apr 30, 2012 12:46 PM|LINK
Hi,
I know this post is so old.. I have a similar scenario now
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?
Request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<Header1 xmlns="http://siebel.com/webservices">
<UsernameToken>midhun.sunny@metrosystems.net</UsernameToken>
<PasswordText>world.1234</PasswordText>
<SessionType>Stateless</SessionType>
</Header1>
</soap:Header>
<soap:Body>
<MG_spcPicking_spcParameter_spcExport_spcV02_spcW_Input xmlns="http://siebel.com/CustomUI" />
</soap:Body>
</soap:Envelope>
Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header>
<siebel-header:SessionToken xmlns:siebel-header="http://siebel.com/webservices">NMJ5kb4xLYKa5OpdbQ61Wrc8nblpEXQ6DprcI50GTKo8keNDX-BxOKJOlfuB3.zcuOs1znmT36iye9ynPr1a8enSrjgzkN12nI9fPlzJNXrO9fnN.nEMYVZj74pCWzdcC9Z-fqZyZ.HLdcrrCU-kLlO0K1LpkN01eXjnFMplwdsHZBKEouqHaUdgkqaZKAd7E0vlD86ClOzDV9zJnFrYxvcfPko0epl1N3Iipa4RLPwNEqg4eAaUPvKBj69F18U8Xl-kHjkVHoZrJjeyYbhtR6bMUaf53eHY</siebel-header:SessionToken>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
----
<soap:Body>
<MG_spcPicking_spcParameter_spcExport_spcV02_spcW_Input xmlns="http://siebel.com/CustomUI" />
</soap:Body>
</soap:Envelope>
Please help..