代码之家  ›  专栏  ›  技术社区  ›  Zack Angelo

AXIS2 SOAP信封标题信息

  •  5
  • Zack Angelo  · 技术社区  · 15 年前

    我正在使用一个web服务,它在SOAP信封头中放置一个身份验证令牌。看起来(通过查看WS-WSDL附带的示例),如果存根是在.NET中生成的,那么这个头信息将通过存根类中的成员变量公开。但是,当我使用WSDL2Java生成我的AxIS2 Java存根时,它似乎不会在任何地方被暴露。

    从SOAP信封头提取此信息的正确方法是什么?

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

    C#样品:

    
    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; 
            }
        }
    }
    

    这个例子说明了我想做什么。请注意 secSvc 实例具有 SecurityHeaderValue 成功后填充的成员变量 secSvc.SignIn() 召唤。

    以下是一些有关 SignIn 方法:

    虽然没有返回值,但成功登录将填充安全服务的SecurityHeaderValue。然后,SecurityHeaderValue信息将用于其他web服务调用。
    1 回复  |  直到 15 年前
        1
  •  2
  •   joelittlejohn    11 年前

    我相信你要找的电话是:

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