Importing xsd into wsdl

前端 未结 2 951
一向
一向 2020-12-25 11:32

This is my current configuration:

XSD




        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-25 11:57

    import vs. include

    The primary purpose of an import is to import a namespace. A more common use of the XSD import statement is to import a namespace which appears in another file. You might be gathering the namespace information from the file, but don't forget that it's the namespace that you're importing, not the file (don't confuse an import statement with an include statement).

    Another area of confusion is how to specify the location or path of the included .xsd file: An XSD import statement has an optional attribute named schemaLocation but it is not necessary if the namespace of the import statement is at the same location (in the same file) as the import statement itself.

    When you do chose to use an external .xsd file for your WSDL, the schemaLocation attribute becomes necessary. Be very sure that the namespace 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:

    WSDL:

    xs:import namespace="urn:listing3" schemaLocation="listing3.xsd"/>
    

    XSD:

     
    

    Another approach to letting know the WSDL about the XSD is through Maven's pom.xml:

    
      org.codehaus.mojo
      xmlbeans-maven-plugin
      
        
          generate-sources-xmlbeans
          generate-sources
          
        xmlbeans
          
        
      
      2.3.3
      true
      
        ${basedir}/src/main/xsd
      
    
    

    You can read more on this in this great IBM article. It has typos such as xsd:import instead of xs:import but otherwise it's fine.

提交回复
热议问题