title: "Duplicate file name" for same WSDL namespace when using web-service from different sub-domains
body: <p><strong>Preface</strong></p>
  
  <p>We are providing customers with our service API. </p>
  
  <p>Each customer has own subdomain (e.g. sergii.ourwebsite.com) and own WSDL URL, it looks like <a href="http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl" rel="nofollow noreferrer">http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl</a></p>
  
  <p>Also, all the websites (including API, of course) using the same codebase.</p>
  
  <p><br /></p>
  
  <p><strong>Problem</strong></p>
  
  <p>Say, two applications on same CF-server. This can easily happen, because some of customer websites are hosted on our servers.</p>
  
  <p>Both trying to use own API WSDL, say:</p>
  
  <pre><code>http://sergii.ourwebsite.com/api/bsapi.cfc?wsdl
  http://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl
  </code></pre>
  
  <p>And here come the problems.</p>
  
  <p>When second website tries to register the web-service, CF throws an error:</p>
  
  <blockquote>
    <p>Name:
    <a href="https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl" rel="nofollow noreferrer">https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl</a>.
    WSDL:
    <a href="https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl" rel="nofollow noreferrer">https://galashyn.ourwebsite.com/api/bsapi.cfc?wsdl</a>.
    org.apache.axis.wsdl.toJava.DuplicateFileException:
    Duplicate file name:
    /opt/coldfusion8/stubs/WS1985941973/api/Bsapi.java.
    Hint: you may have mapped two
    namespaces with elements of the same
    name to the same package name. It is
    recommended that you use a web browser
    to retrieve and examine the requested
    WSDL document to ensure it is correct.
    If the requested WSDL document cannot
    be retrieved or is dynamically
    generated, it is likely that the
    target web service has programming
    errors.</p>
  </blockquote>
  
  <p>Problem is that both of them are using same WSDL namespace, built from CFC path:</p>
  
  <pre><code>&lt;wsdl:definitions targetNamespace="http://api"&gt;
  </code></pre>
  
  <p><br /></p>
  
  <p><strong>Current solution</strong></p>
  
  <p>The only working solution for us is using the CFC aliases, like:</p>
  
  <pre><code>http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc?wsdl
  http://galashyn.ourwebsite.com/api/v1n1/bsapi.cfc?wsdl
  </code></pre>
  
  <p>Each this CFC extends the parent like this:</p>
  
  <pre><code>&lt;cfcomponent output="false" extends="api.bsapi"&gt;
  &lt;!--- this component used to extend base api version 1.x ---&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p>They produce different namespaces, which can be used without problems -- own namespace for each application:</p>
  
  <pre><code>&lt;wsdl:definitions targetNamespace="http://v1n1.api"&gt;
  &lt;wsdl:definitions targetNamespace="http://v1n2.api"&gt;
  </code></pre>
  
  <p><br /></p>
  
  <p>This is pretty dumb workaround, but it works for now.</p>
  
  <p><br /></p>
  
  <p>Other solution would be to use the single API sub-domain and identifying the customers by some key (we are already using them for security purposes), but it has serious negative problems for us because of some legacy code.</p>
  
  <p><br /></p>
  
  <p>Please note that I don't know Java, so many specific advices are not so clear for me. </p>
  
  <p>Google shows that this problem exists for years, but I can't find the smart solution. </p>
  
  <p>So maybe here?</p>