Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axis2 SOAP Envelope Header Information

I'm consuming a web service that places an authentication token in the SOAP envelope header. It appears (through looking at the samples that came with the WS WSDL) that if the stub is generated in .NET, this header information is exposed through a member variable in the stub class. However, when I generate my Axis2 java stub using WSDL2Java it doesn't appear to be exposed anywhere.

What is the correct way to extract this information from the SOAP envelope header?

WSDL: http://www.vbar.com/zangelo/SecurityService.wsdl

C# Sample:


using System;
using SignInSample.Security;           // web service 
using SignInSample.Document;           // web service

namespace SignInSample
{
    class SignInSampleClass
    {
        [STAThread]
        static void Main(string[] args)
        {
            // login to the Vault and set up the document service
            SecurityService secSvc = new SecurityService();
            secSvc.Url = "http://localhost/AutodeskDM/Services/SecurityService.asmx";
            secSvc.SecurityHeaderValue = new SignInSample.Security.SecurityHeader();

            secSvc.SignIn("Administrator", "", "Vault");

            DocumentServiceWse docSvc = new DocumentServiceWse();
            docSvc.Url = "http://localhost/AutodeskDM/Services/DocumentService.asmx";
            docSvc.SecurityHeaderValue = new SignInSample.Document.SecurityHeader();
            docSvc.SecurityHeaderValue.Ticket = secSvc.SecurityHeaderValue.Ticket;
            docSvc.SecurityHeaderValue.UserId = secSvc.SecurityHeaderValue.UserId; 
        }
    }
}

The sample illustrates what I'd like to do. Notice how the secSvc instance has a SecurityHeaderValue member variable that is populated after a successful secSvc.SignIn() invocation.

Here's some relevant API documentation regarding the SignIn method:

Although there is no return value, a successful sign in will populate the SecurityHeaderValue of the security service. The SecurityHeaderValue information is then used for other web service calls.
like image 996
Zack Angelo Avatar asked Nov 06 '22 20:11

Zack Angelo


1 Answers

I believe the call you're looking for is:

MessageContext.getCurrentMessageContext().getEnvelope().getHeader()

like image 112
joelittlejohn Avatar answered Nov 11 '22 16:11

joelittlejohn