You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "EasternWahoo (JIRA)" <ji...@apache.org> on 2015/06/01 21:33:19 UTC

[jira] [Commented] (CXF-6413) WSDL Import SchemaLocation Error on Relative Path

    [ https://issues.apache.org/jira/browse/CXF-6413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567858#comment-14567858 ] 

EasternWahoo commented on CXF-6413:
-----------------------------------

We have the same problem in CXF 3.0.3 when schema imports use subfolders.  SoapUI cannot import the wsdl due to this error. 
Without subfolders, CXF correctly patches the schemalocation, as required by the JAXWS specfication.  For example, when the schema or wsdl contains this import: 
<w3c:import schemaLocation="addressService.xsd"  ... />
 CXF's wsdl/xsd resolves the schema location appropriately, i.e., 
<w3c:import ... schemaLocation="http://localhost:8080/sandbox-soapjms/services/addressService?xsd=addressService.xsd"/> 				... /> 

However, when subfolders are included in the relative URL, CXF does not patch the url.  When attempting to read the unpatched URL in Tomcat, the URL is relative to the Tomcat install directory, resulting in a "404 not found".  

> 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
>             Fix For: 3.1.1
>
>         Attachments: SchemaLocation.zip
>
>
> 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"));".
> {code:title=mapUri() with problem|borderStyle=solid}
>   protected String mapUri(String base, Map<String, SchemaReference> smp, String loc, String xsd) throws UnsupportedEncodingException
>   {
>     String key = loc;
>     try {
>       boolean absoluteLocUri = new URI(loc).isAbsolute();
>       if ((!absoluteLocUri) && (xsd != null)) {
>         key = new URI(xsd).resolve(loc).toString();
>       }
>       if ((!absoluteLocUri) && (xsd == null))
>         key = new URI(".").resolve(loc).toString();
>     }
>     catch (URISyntaxException e)
>     {
>     }
>     SchemaReference ref = (SchemaReference)smp.get(URLDecoder.decode(key, "utf-8"));
>     if (ref != null) {
>       return new StringBuilder().append(base).append("?xsd=").append(key.replace(" ", "%20")).toString();
>     }
>     return null;
>   }
> {code}
> 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)