Howto prevent JBoss from rewriting JAX-WS XSD import URLs to HTTPs

左心房为你撑大大i 提交于 2019-12-13 01:10:15

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/35779040/howto-prevent-jboss-from-rewriting-jax-ws-xsd-import-urls-to-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!