我使用 Maven 插件 (org.codehaus.mojo
> axistools-maven-plugin
) + WSDL 文件来生成 Soap Web 服务。
在 target/generated-source/wsdl2java/com.comp.proj 中生成的文件是:
- Foo.java(java接口(interface))
- FooServiceLocator.java
- FooSoapBindingImpl.java(java 空实现)
- FooSoapBindingSkeleton.java
- FooSoapBindingStub.java
在我的项目中,我在同名包中创建了 FooSoapBindingImpl.java
+ 在此 java 实现中添加了我的自定义代码。
此 Web 服务已准备好在生产中使用。
所以,今天我在我的客户端上添加了基本身份验证(header => Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==)
如何在我的 Axis Web 服务中添加对此基本身份验证的检查?
最佳答案
“Axis security section 'Authenticating the caller'”提到:
Clients can authenticate themselves with client certificates, or HTTP basic authentication.
The latter is too weak to be trustable on a non-encrypted channel, but works over HTTPS.The
MessageContext
class will be configured with the username and password of the sender when SOAP messages are posted to the endpoint;*
参见 an example here .
use the appropriate getters to see these values. Note that Axis does not yet integrate with the servlet API authentication stuff.
关于java - 如何在 Apache Axis Web 服务 (SOAP) 中添加基本身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48889398/