我在笔记本电脑中安装了Tomcat 7.0和apache axis2。我已经部署了 一个简单的基于SOAP的Web服务。 Web服务部署成功,日志文件中没有错误,也获得成功的消息。 当我尝试实现基于Tomcat容器的身份验证(基本)时 使用web.xml,它无法正常工作。所有正确的库都存在于lib文件夹中。
<security-role>
<description>Normal operator user</description>
<role-name>operator</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Operator Roles Security</web-resource-name>
<url-pattern>/services/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>operator</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<role-name>operator</role-name>
</login-config>
<servlet-mapping>
<servlet-name>com.kathy.ws.UserProfile</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
----------------------------------------tomcat users.xml--------
<role rolename="tomcat"/>
<role rolename="operator"/>
<user username="tomcat" password="welcome1" roles="tomcat"/>
<user username="both" password="welcome1" roles="tomcat,operator"/>
<user username="operator" password="welcome1" roles="operator"/>
-------------------------sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="UserProfileImpl"
implementation="com.kathy.ws.UserProfile"
url-pattern="/services/UserProfile"/>
</endpoint>
</endpoints>