2009-08-24 84 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()