Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>import vs. include</strong></p> <p>The primary purpose of an import is to import a <em>namespace</em>. A more common use of the XSD import statement is to import a <em>namespace</em> which appears in another file. You might be gathering the namespace information from the file, but don't forget that it's the <strong>namespace</strong> that you're importing, <strong>not the file</strong> (don't confuse an <code>import</code> statement with an <code>include</code> statement).</p> <p>Another area of confusion is how to specify the location or path of the included <code>.xsd</code> file: An XSD import statement has an optional attribute named <code>schemaLocation</code> but it is not necessary <strong>if</strong> the namespace of the import statement is at the same location (in the same file) as the import statement itself.</p> <p>When you do chose to use an external <code>.xsd</code> file for your WSDL, the <code>schemaLocation</code> attribute becomes necessary. Be very sure that the <em>namespace</em> you use in the import statement is the same as the targetNamespace of the schema you are importing. That is, all 3 occurrences must be identical:</p> <p><strong>WSDL:</strong></p> <pre><code>xs:import namespace="urn:listing3" schemaLocation="listing3.xsd"/&gt; </code></pre> <p><strong>XSD:</strong></p> <pre><code>&lt;xsd:schema targetNamespace="urn:listing3" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; </code></pre> <p>Another approach to letting know the WSDL about the XSD is through Maven's pom.xml:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;xmlbeans-maven-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;generate-sources-xmlbeans&lt;/id&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;xmlbeans&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;version&gt;2.3.3&lt;/version&gt; &lt;inherited&gt;true&lt;/inherited&gt; &lt;configuration&gt; &lt;schemaDirectory&gt;${basedir}/src/main/xsd&lt;/schemaDirectory&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>You can read more on this in this <a href="http://www.ibm.com/developerworks/webservices/library/ws-tip-imports/" rel="noreferrer">great IBM article</a>. It has typos such as <code>xsd:import</code> instead of <code>xs:import</code> but otherwise it's fine.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload