Search code examples
xmlweb-servicesxsdwsdl

WSDL schemaLocation : Is it possible to import a .xsd into a .wsdl using a relative path?


Here is my WSDL :

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions targetNamespace="http://xxx" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns0="http://xxx/commun/axis" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://xxx" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

     <wsdl:types>
          <xsd:schema targetNamespace="http://xxx/commun/axis" xmlns="http://www.w3.org/2001/XMLSchema">
               <xsd:include schemaLocation="https://host:port/path/WebServices/wsdl/typesServicesApplicatifs.xsd"/>
(...)

The typesServicesApplicatifs.xsd file is in the same directory as the WSDL file (inside a war), is it possible tu use a relative path instead of an absolute path for the schema location ?

It would be really helpful, because for now, the schemaLocation is different on each environnment (the host and the port have to be specified).

EDIT : this question is the same as the last one in this thread (with no answer) : http://forum.springsource.org/showthread.php?p=342542


Solution

  • Here is a way to achieve this :

    Using Spring-WS, the WSDL can be generated automatically from :

    <sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" **locationUri="/holidayService/"** targetNamespace="http://mycompany.com/hr/definitions">
      <sws:xsd location="/WEB-INF/hr.xsd"/>
    </sws:dynamic-wsdl>
    

    source : http://static.springsource.org/spring-ws/site/reference/html/tutorial.html#tutorial-publishing-wsdl

    This way, the host, port and context path don't need to be specified inside the WSDL.