简体   繁体   English

Java Soap 服务添加用户名令牌 Header

[英]Java Soap Service Add UsernameToken Header

I am using Axis2 for generate code from wsdl.我正在使用 Axis2 从 wsdl 生成代码。 I can call soap service via stub class and it is ok.我可以通过存根 class 调用 soap 服务,没关系。 But i have to send soap header like below.但我必须发送 soap header 如下所示。 How can i do this?我怎样才能做到这一点?

<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-6"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile- 
1.0#PasswordText">password</wsse:Password>
<wsse:NonceEncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message- 
security-1.0#Base64Binary">randomnaumber==</wsse:Nonce>
<wsu:Created>dateCreated</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>

You need to configure Web service security (WSS4J) Interceptors (both client and server side) to enable username, password authentication.您需要配置 Web 服务安全 (WSS4J) 拦截器(客户端和服务器端)以启用用户名、密码验证。 So that you could send headers like you mentioned.这样你就可以像你提到的那样发送标题。 Either you could create a configuration class or use xml based configuration.您可以创建配置 class 或使用基于 xml 的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM