我有在 weblogic 服务器上正确配置的 SOAP web 服务,但我试图让它在 Tomcat 上运行。
在我的 tomcat-users.xml 中我有这样的用户配置
<tomcat-users version="1.0" xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
<role rolename="esknusers"/>
<user password="password" roles="esknusers" username="esknuser"/>
</tomcat-users>
在我的 web.xml 中,web 服务是这样配置的
<security-constraint>
<display-name>SecurityConstraint_ESKN</display-name>
<web-resource-collection>
<web-resource-name>ESKNWS</web-resource-name>
<url-pattern>/ESKN_WS</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>esknusers</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<role-name>esknusers</role-name>
</security-role>
当我尝试通过 SOAP-UI 调用此 Web 服务时,它总是返回 403。知道可能是什么问题吗?
在 Soap-ui 中,我通过名称和密码使用基本身份验证
来自 SOAP-UI 的消息:
Access to the requested resource has been denied - The server understood the request but refuses to authorize it
最佳答案
您已经设置了角色名称,但您还需要在 web.xml
文件中添加以下内容来告诉 Tomcat 您正在使用 BASIC 身份验证:
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Basic Authentication</realm-name>
</login-config>
这应该默认从您的 conf/tomcat-users.xml
文件中读取用户名和密码。
关于java - 为 Tomcat 配置 SOAP - 请求总是被拒绝 (403),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52930574/