[ https://issues.apache.org/jira/browse/CXF-6413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jader da Silva Santos updated CXF-6413: --------------------------------------- Description: When importing multiple levels of XSDs in a WSDL, the schemaLocation attribute produces an error in the translated URL. Folder Structure: {noformat} wsdl | +--UserService wsdl | +--schema | +--type | | | +-- user | | | +--user xsd | +-- phone | | | +--phone xsd +--xsd | +--UserService xsd {noformat} {code:title=UserService.wsdl|borderStyle=solid} <?xml version='1.0' encoding='UTF-8'?> <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test.com.br/integration/services/user" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:sch="http://test.com.br/integration/schema" name="UserServiceService" targetNamespace="http://test.com.br/integration/services/user"> <wsdl:types> <xsd:schema> <xsd:import namespace="http://test.com.br/integration/schema" schemaLocation="../schema/xsd/UserService.xsd" /> </xsd:schema> </wsdl:types> <wsdl:message name="helloResponse"> <wsdl:part element="sch:helloResponse" name="parameters" /> </wsdl:message> <wsdl:message name="hello"> <wsdl:part element="sch:hello" name="parameters" /> </wsdl:message> <wsdl:portType name="UserService"> <wsdl:operation name="hello"> <wsdl:input message="tns:hello" name="hello" /> <wsdl:output message="tns:helloResponse" name="helloResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="UserServiceServiceSoapBinding" type="tns:UserService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="hello"> <soap:operation soapAction="" style="document" /> <wsdl:input name="hello"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="helloResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="UserServiceService"> <wsdl:port binding="tns:UserServiceServiceSoapBinding" name="UserServicePort"> <soap:address location="http://localhost:8080/SchemaLocation/UserService" /> </wsdl:port> </wsdl:service> </wsdl:definitions> {code} {code:title=UserService.xsd|borderStyle=solid} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://test.com.br/integration/schema" xmlns:ns2="http://test.com.br/integration/schema/user" elementFormDefault="unqualified" targetNamespace="http://test.com.br/integration/schema" version="1.0"> <xs:import namespace="http://test.com.br/integration/schema/user" schemaLocation="../type/user/user.xsd" /> <xs:element name="hello" type="tns:hello" /> <xs:element name="helloResponse" type="tns:helloResponse" /> <xs:complexType name="hello"> <xs:sequence> <xs:element minOccurs="0" name="arg0" type="ns2:user" /> </xs:sequence> </xs:complexType> <xs:complexType name="helloResponse"> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:schema> {code} {code:title=user.xsd|borderStyle=solid} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://test.com.br/integration/schema/phone" targetNamespace="http://test.com.br/integration/schema/user" version="1.0"> <xs:import namespace="http://test.com.br/integration/schema/phone" schemaLocation="../phone/phone.xsd" /> <xs:complexType name="user"> <xs:sequence> <xs:element minOccurs="0" name="name" type="xs:string" /> <xs:element minOccurs="0" name="lastName" type="xs:string" /> <xs:element minOccurs="0" name="phone" type="ns1:phone" /> </xs:sequence> </xs:complexType> </xs:schema> {code} {code:title=phone.xsd|borderStyle=solid} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.com.br/integration/schema/phone" version="1.0"> <xs:complexType name="phone"> <xs:sequence> <xs:element minOccurs="0" name="countryCode" type="xs:int" /> <xs:element minOccurs="0" name="areaCode" type="xs:int" /> <xs:element minOccurs="0" name="number" type="xs:long" /> </xs:sequence> </xs:complexType> </xs:schema> {code} Error: When running on started server, the schemaLocation attribute in UserService.xsd don't resolve the absolute path, causing error. WSDLGetUtils.java In 2.7.7 version of CXF library, mapUri() method resolves correctly. {code:title=mapUri()|borderStyle=solid} protected String mapUri(String base, Map<String, SchemaReference> smp, String loc) throws UnsupportedEncodingException { SchemaReference ref = (SchemaReference) smp.get(URLDecoder.decode(loc, "utf-8")); if (ref != null) { return new StringBuilder().append(base).append("?xsd=") .append(ref.getSchemaLocationURI().replace(" ", "%20")).toString(); } return null; } {code} After 2.7.7 version, for example 3.1.0 version, mapUri() was changed. The "loc" parameter is changed in this line "key = new URI(xsd).resolve(loc).toString();". After that change, the imported XSD is not found on the map "SchemaReference ref = (SchemaReference)smp.get(URLDecoder.decode(key, "utf-8"));". This error is blocking WSDL first aproach development using JBoss AS and JAX-WS. was: When importing multiple levels of XSDs in a WSDL, the schemaLocation attribute produces an error in the translated URL. Folder Structure: {noformat} wsdl | +--UserService wsdl | +--schema | +--type | | | +-- user | | | +--user xsd | +-- phone | | | +--phone xsd +--xsd | +--UserService xsd {noformat} ---------------------------------------------------------------------------------------------- UserService.wsdl ---------------------------------------------------------------------------------------------- {noformat} <?xml version='1.0' encoding='UTF-8'?> <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test.com.br/integration/services/user" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:sch="http://test.com.br/integration/schema" name="UserServiceService" targetNamespace="http://test.com.br/integration/services/user"> <wsdl:types> <xsd:schema> <xsd:import namespace="http://test.com.br/integration/schema" schemaLocation="../schema/xsd/UserService.xsd" /> </xsd:schema> </wsdl:types> <wsdl:message name="helloResponse"> <wsdl:part element="sch:helloResponse" name="parameters" /> </wsdl:message> <wsdl:message name="hello"> <wsdl:part element="sch:hello" name="parameters" /> </wsdl:message> <wsdl:portType name="UserService"> <wsdl:operation name="hello"> <wsdl:input message="tns:hello" name="hello" /> <wsdl:output message="tns:helloResponse" name="helloResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="UserServiceServiceSoapBinding" type="tns:UserService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="hello"> <soap:operation soapAction="" style="document" /> <wsdl:input name="hello"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="helloResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="UserServiceService"> <wsdl:port binding="tns:UserServiceServiceSoapBinding" name="UserServicePort"> <soap:address location="http://localhost:8080/SchemaLocation/UserService" /> </wsdl:port> </wsdl:service> </wsdl:definitions> {noformat} ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- UserService.xsd ---------------------------------------------------------------------------------------------- {noformat} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://test.com.br/integration/schema" xmlns:ns2="http://test.com.br/integration/schema/user" elementFormDefault="unqualified" targetNamespace="http://test.com.br/integration/schema" version="1.0"> <xs:import namespace="http://test.com.br/integration/schema/user" schemaLocation="../type/user/user.xsd" /> <xs:element name="hello" type="tns:hello" /> <xs:element name="helloResponse" type="tns:helloResponse" /> <xs:complexType name="hello"> <xs:sequence> <xs:element minOccurs="0" name="arg0" type="ns2:user" /> </xs:sequence> </xs:complexType> <xs:complexType name="helloResponse"> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:schema> {noformat} ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- user.xsd ---------------------------------------------------------------------------------------------- {noformat} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://test.com.br/integration/schema/phone" targetNamespace="http://test.com.br/integration/schema/user" version="1.0"> <xs:import namespace="http://test.com.br/integration/schema/phone" schemaLocation="../phone/phone.xsd" /> <xs:complexType name="user"> <xs:sequence> <xs:element minOccurs="0" name="name" type="xs:string" /> <xs:element minOccurs="0" name="lastName" type="xs:string" /> <xs:element minOccurs="0" name="phone" type="ns1:phone" /> </xs:sequence> </xs:complexType> </xs:schema> {noformat} ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- phone.xsd ---------------------------------------------------------------------------------------------- {noformat} <?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.com.br/integration/schema/phone" version="1.0"> <xs:complexType name="phone"> <xs:sequence> <xs:element minOccurs="0" name="countryCode" type="xs:int" /> <xs:element minOccurs="0" name="areaCode" type="xs:int" /> <xs:element minOccurs="0" name="number" type="xs:long" /> </xs:sequence> </xs:complexType> </xs:schema> {noformat} ---------------------------------------------------------------------------------------------- Error: When running on started server, the schemaLocation attribute in UserService.xsd don't resolve the absolute path, causing error. WSDLGetUtils.java In 2.7.7 version of CXF library, mapUri() method resolves correctly. {noformat} protected String mapUri(String base, Map<String, SchemaReference> smp, String loc) throws UnsupportedEncodingException { SchemaReference ref = (SchemaReference) smp.get(URLDecoder.decode(loc, "utf-8")); if (ref != null) { return new StringBuilder().append(base).append("?xsd=") .append(ref.getSchemaLocationURI().replace(" ", "%20")).toString(); } return null; } {noformat} After 2.7.7 version, for example 3.1.0 version, mapUri() was changed. The "loc" parameter is changed in this line "key = new URI(xsd).resolve(loc).toString();". After that change, the imported XSD is not found on the map "SchemaReference ref = (SchemaReference)smp.get(URLDecoder.decode(key, "utf-8"));". This error is blocking WSDL first aproach development using JBoss AS and JAX-WS. > WSDL Import SchemaLocation Error on Relative Path > ------------------------------------------------- > > Key: CXF-6413 > URL: https://issues.apache.org/jira/browse/CXF-6413 > Project: CXF > Issue Type: Bug > Components: Core > Affects Versions: 2.7.11, 2.7.13, 3.1.0 > Environment: Wildfly 8.1; Windows 7 > Reporter: Jader da Silva Santos > > When importing multiple levels of XSDs in a WSDL, the schemaLocation > attribute produces an error in the translated URL. > Folder Structure: > {noformat} > wsdl > | > +--UserService wsdl > | > +--schema > | > +--type > | | > | +-- user > | | > | +--user xsd > | +-- phone > | | > | +--phone xsd > +--xsd > | > +--UserService xsd > {noformat} > {code:title=UserService.wsdl|borderStyle=solid} > <?xml version='1.0' encoding='UTF-8'?> > <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > xmlns:tns="http://test.com.br/integration/services/user" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns:ns1="http://schemas.xmlsoap.org/soap/http" > xmlns:sch="http://test.com.br/integration/schema" > name="UserServiceService" > targetNamespace="http://test.com.br/integration/services/user"> > <wsdl:types> > <xsd:schema> > <xsd:import > namespace="http://test.com.br/integration/schema" > schemaLocation="../schema/xsd/UserService.xsd" /> > </xsd:schema> > </wsdl:types> > <wsdl:message name="helloResponse"> > <wsdl:part element="sch:helloResponse" name="parameters" /> > </wsdl:message> > <wsdl:message name="hello"> > <wsdl:part element="sch:hello" name="parameters" /> > </wsdl:message> > <wsdl:portType name="UserService"> > <wsdl:operation name="hello"> > <wsdl:input message="tns:hello" name="hello" /> > <wsdl:output message="tns:helloResponse" > name="helloResponse" /> > </wsdl:operation> > </wsdl:portType> > <wsdl:binding name="UserServiceServiceSoapBinding" > type="tns:UserService"> > <soap:binding style="document" > transport="http://schemas.xmlsoap.org/soap/http" /> > <wsdl:operation name="hello"> > <soap:operation soapAction="" style="document" /> > <wsdl:input name="hello"> > <soap:body use="literal" /> > </wsdl:input> > <wsdl:output name="helloResponse"> > <soap:body use="literal" /> > </wsdl:output> > </wsdl:operation> > </wsdl:binding> > <wsdl:service name="UserServiceService"> > <wsdl:port binding="tns:UserServiceServiceSoapBinding" > name="UserServicePort"> > <soap:address > location="http://localhost:8080/SchemaLocation/UserService" /> > </wsdl:port> > </wsdl:service> > </wsdl:definitions> > {code} > {code:title=UserService.xsd|borderStyle=solid} > <?xml version='1.0' encoding='UTF-8'?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:tns="http://test.com.br/integration/schema" > xmlns:ns2="http://test.com.br/integration/schema/user" > elementFormDefault="unqualified" > targetNamespace="http://test.com.br/integration/schema" > version="1.0"> > <xs:import namespace="http://test.com.br/integration/schema/user" > schemaLocation="../type/user/user.xsd" /> > <xs:element name="hello" type="tns:hello" /> > <xs:element name="helloResponse" type="tns:helloResponse" /> > <xs:complexType name="hello"> > <xs:sequence> > <xs:element minOccurs="0" name="arg0" type="ns2:user" /> > </xs:sequence> > </xs:complexType> > <xs:complexType name="helloResponse"> > <xs:sequence> > <xs:element minOccurs="0" name="return" > type="xs:string" /> > </xs:sequence> > </xs:complexType> > </xs:schema> > {code} > {code:title=user.xsd|borderStyle=solid} > <?xml version='1.0' encoding='UTF-8'?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:ns1="http://test.com.br/integration/schema/phone" > targetNamespace="http://test.com.br/integration/schema/user" > version="1.0"> > <xs:import namespace="http://test.com.br/integration/schema/phone" > schemaLocation="../phone/phone.xsd" /> > <xs:complexType name="user"> > <xs:sequence> > <xs:element minOccurs="0" name="name" type="xs:string" > /> > <xs:element minOccurs="0" name="lastName" > type="xs:string" /> > <xs:element minOccurs="0" name="phone" type="ns1:phone" > /> > </xs:sequence> > </xs:complexType> > </xs:schema> > {code} > {code:title=phone.xsd|borderStyle=solid} > <?xml version='1.0' encoding='UTF-8'?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://test.com.br/integration/schema/phone" > version="1.0"> > <xs:complexType name="phone"> > <xs:sequence> > <xs:element minOccurs="0" name="countryCode" > type="xs:int" /> > <xs:element minOccurs="0" name="areaCode" type="xs:int" > /> > <xs:element minOccurs="0" name="number" type="xs:long" > /> > </xs:sequence> > </xs:complexType> > </xs:schema> > {code} > Error: > When running on started server, the schemaLocation attribute in > UserService.xsd don't resolve the absolute path, causing error. > WSDLGetUtils.java > In 2.7.7 version of CXF library, mapUri() method resolves correctly. > {code:title=mapUri()|borderStyle=solid} > protected String mapUri(String base, Map<String, SchemaReference> smp, String > loc) > throws UnsupportedEncodingException { > SchemaReference ref = (SchemaReference) > smp.get(URLDecoder.decode(loc, "utf-8")); > if (ref != null) { > return new StringBuilder().append(base).append("?xsd=") > > .append(ref.getSchemaLocationURI().replace(" ", "%20")).toString(); > } > return null; > } > {code} > After 2.7.7 version, for example 3.1.0 version, mapUri() was changed. The > "loc" parameter is changed in this line "key = new > URI(xsd).resolve(loc).toString();". After that change, the imported XSD is > not found on the map "SchemaReference ref = > (SchemaReference)smp.get(URLDecoder.decode(key, "utf-8"));". > This error is blocking WSDL first aproach development using JBoss AS and > JAX-WS. -- This message was sent by Atlassian JIRA (v6.3.4#6332)