如何限制除了wsdl之外的所有内容?

Ili*_*hko 4 java security tomcat wsdl web-services

我在Tomcat 6下部署了一个web服务,它运行得很好.现在我想验证任何客户端,但是通过http:// localhost:8080/services/MyService这样的URL保持wsdl公共访问 ?wsdl

我试图以这种方式解决问题(webapp的web.xml),但它不起作用:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>WSDL access - to anybody</web-resource-name>
        <url-pattern>/services/MyService?wsdl</url-pattern>
    </web-resource-collection>

    <auth-constraint><role-name>*</role-name></auth-constraint>      
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Some authentification required</web-resource-name>
        <url-pattern>/services/MyService</url-pattern>
    </web-resource-collection>

    <auth-constraint><role-name>somebody</role-name></auth-constraint>          
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

我现在看到的唯一解决方案是创建额外的servlet并赋予访问WSDL的一个权限.servlet会将所需的wsdl传递给客户端,无论它是否经过身份验证.在这种情况下,WSDL URL不是obvius,所以我不喜欢这个解决方案.还有其他任何建议吗?

Dan*_*lor 8

我有类似的问题,我找到了解决方案.通过POST调用WebServices方法,而通过GET获取WSDL.因此解决方案是仅限制POST访问.

security-constraint>
    <web-resource-collection>
        <web-resource-name>Some authentification required</web-resource-name>
        <url-pattern>/services/MyService</url-pattern>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint><role-name>somebody</role-name></auth-constraint>          
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

我正在将WebSphere 7与JAXWS一起使用,但web.xml配置对于所有容器和应用程序服务器都是相同的.