如何防止JBoss将JAX-WS XSD导入URL重写为HTTP [英] Howto prevent JBoss from rewriting JAX-WS XSD import URLs to HTTPs

查看:109
本文介绍了如何防止JBoss将JAX-WS XSD导入URL重写为HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在JBoss EAP 6.4.0(JBoss AS 7.5.0)的WAR中部署了JAX-WS Web服务,该服务提供了预定义的WSDL和XSD:

@WebService(endpointInterface = "package.MyPortType",
    targetNamespace = "http://target.name.space",
    wsdlLocation = "/WEB-INF/classes/myService.wsdl",
    serviceName = "myService",
    portName = "myServicePort")
public class MyService implements MyPortType {
...
}

JBoss正确部署了Web服务,并将给定的WSDL发布为 http://localhost:8080/myApp/myService http://localhost:8080/myApp/myService?wsdl

我们遇到的问题在于WSDL中的XSD导入.在原始的WSDL中,它看起来像:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="mySchema.xsd" />

但是JBoss将其重写为

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="https://localhost:8443/myApp/myService?xsd=mySchema.xsd" />

这不起作用,因为我们在standalone.xml中都没有定义HTTPs连接器和HTTPs套接字绑定.因此,JBoss在没有任何HTTPs连接的情况下运行. 我们没有有关Web服务部署的任何其他配置文件.

为什么以这种错误的方式重写进口,我们如何防止这种情况发生?

解决方案

根据JAX-WS规范:

JAX-WS实现必须修补指向本地文档的本地文档中所有wsdl:importxsd:import语句的位置属性 ...

...请注意,尽管目录工具(请参阅4.4)用于解析在处理根描述文档或通过wsdl:importxsd:import语句可传递的所有文档时遇到的任何绝对URL,但是发布导入文档时,绝对URL不会被重写,因为通过目录解析的文档不被视为本地文档,即使目录将它们映射到与应用程序打包在一起的资源上.

所以您有为什么位置被重写的原因,特别是因为XSD是本地的.

为避免重写,您需要在原始WSDL的schemaLocation字段中指定您选择的绝对URL.

为什么错误地重写了位置? 一些聊天. /browse/WFLY-5228?jql = text%20〜%20%22schemalocation%20rewrite%22"rel =" nofollow> JBoss发行板可能表明您的JAX-WS实现中存在错误

We have a JAX-WS webservice deployed in a WAR in JBoss EAP 6.4.0 (JBoss AS 7.5.0) that delivers a predefined WSDL and XSD:

@WebService(endpointInterface = "package.MyPortType",
    targetNamespace = "http://target.name.space",
    wsdlLocation = "/WEB-INF/classes/myService.wsdl",
    serviceName = "myService",
    portName = "myServicePort")
public class MyService implements MyPortType {
...
}

JBoss correctly deploys the webservice and publishes the given WSDL as http://localhost:8080/myApp/myService and http://localhost:8080/myApp/myService?wsdl

The problem we encounter lies in the XSD import in the WSDL. In the original WSDL it looks like:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="mySchema.xsd" />

But JBoss rewrites this to

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ...>
<types>
    <xsd:schema targetNamespace="http://target.name.space">
        <xsd:import namespace="http://target.name.space"
            schemaLocation="https://localhost:8443/myApp/myService?xsd=mySchema.xsd" />

And this does not work because we have neither a HTTPs connector nor HTTPs socket binding defined in standalone.xml. So JBoss is running without any HTTPs connectivity. We do not have any additional configuration files regarding the web service deployment.

Why are the imports rewritten in such an erroneous way and how can we prevent this?

解决方案

From the JAX-WS spec:

A JAX-WS implementation MUST patch the location attributes of all wsdl:import and xsd:import statement in local documents that point to local documents...

...Please note that, although the catalog facility (see 4.4) is used to resolve any absolute URLs encountered while processing the root description document or any documents transitively reachable from it via wsdl:import and xsd:import statements, those absolute URLs will not be rewritten when the importing document is published, since documents resolved via the catalog are not considered local, even if the catalog maps them to resources packaged with the application.

So you have why the location is being rewritten, specifically because the XSD is local.

To avoid the rewrite, you need to specify an absolute URL of your choosing in the schemaLocation field in the original WSDL.

As to why the location is being rewritten erroneously? There's some chatter on the JBoss issue board that might indicate that there's a bug in your JAX-WS implementation

这篇关于如何防止JBoss将JAX-WS XSD导入URL重写为HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆