2009-08-24 147 views
5

我正在使用将SOAP身份验证令牌放置在SOAP信封头中的Web服务。它看起来(通过查看WS WSDL附带的示例),如果存根是在.NET中生成的,则此头信息通过存根类中的成员变量显示。但是,当我使用WSDL2Java生成我的Axis2 java存根时,它看起来并没有暴露在任何地方。Axis2 SOAP信封头信息

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

该示例说明了我想要做什么。请注意0​​实例是如何在成功调用secSvc.SignIn()后填充的SecurityHeaderValue成员变量。

下面是关于SignIn方法的一些相关的API文档:

虽然没有返回值,一个成功的标志将填充安全服务的SecurityHeaderValue。 SecurityHeaderValue信息然后用于其他Web服务调用。
+0

你可以举个例子,张贴WSDL,任何具体? – skaffman 2009-08-24 21:54:18

+0

我有同样的问题 – LiorH 2010-12-23 15:13:35

回答

1

我相信你正在寻找呼叫:

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