我正在使用一个将身份验证令牌放在 SOAP 信封头中的 Web 服务。看来(通过查看随 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
以下是有关该方法的一些相关 API 文档:
虽然没有返回值,但成功登录会填充安全服务的 SecurityHeaderValue。然后将 SecurityHeaderValue 信息用于其他 Web 服务调用。