An <xsd:schema ...> element needs to be completely valid by itself. Thus, if it references types outside of itself, it MUST import the other schemas. In a WSDL, if another <xsd:schema> defines the types, you just need:
<xsd:import namespace="....."/> without a location. This allows the schema resolver to look at the other schemas that are being loaded at the same time to find one that matches the namespace. In you example, the second schema uses types defined outside of it, but doesn't have any <xsd:import> statements. Dan On Tue March 24 2009 9:41:35 am Andrew Clegg wrote: > I'm not sure I follow you -- the service-specific schema > ws_spindlep_2_0_ws0.xsd has this line as the first element in its > schema: > > <xsd:import namespace="http://www.cbs.dtu.dk/ws/ws-common" > schemaLocation="../common/ws_common_1_0b.xsd"/> > > ... which is also imported into the WSDL. > > I just noticed last night though that Eclipse complains about the WSDL > having two wsdl:types elements, I'll try merging them and see if that > makes JAXB happy... > > Andrew. > > 2009/3/23 Daniel Kulp <[email protected]>: > > JAXB is correct here. The scheme in question (the second in the wsdl), > > doesn't have any imports. Thus, it cannot reference anything outside of > > itself. There should be an import in there. > > > > Dan > > > > On Mon March 23 2009 3:40:22 pm Andrew Clegg wrote: > >> Actually, I think my previous suspicion about the cause of the problem > >> may be a red herring. > >> > >> I've downloaded all three files: > >> > >> http://www.cbs.dtu.dk/ws/SpindleP/SpindleP_2_0_ws0.wsdl > >> http://www.cbs.dtu.dk/ws/SpindleP/ws_spindlep_2_0_ws0.xsd > >> http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd > >> > >> and saved them into one local directory, changed the schemaLocation > >> elements to just refer to the filenames without any path prefixes: > >> > >> <xsd:import > >> namespace="http://www.cbs.dtu.dk/ws/ws-common" > >> schemaLocation="ws_common_1_0b.xsd" > >> /> > >> > >> and invoked wsdl2java like so: > >> > >> wsdl2java SpindleP_2_0_ws0.wsdl > >> > >> and I still get: > >> > >> WSDLToJava Error: Thrown by JAXB : undefined simple or complex type > >> 'spindlep:seqlookup' > >> > >> This service works fine in SoapUI, I've sent, received and validated > >> messages OK, so I'm a bit stuck... Is there some magic incantation > >> that gets wsdl2java to honour imported schemas? > >> > >> Any suggestions greatly appreciated! > >> > >> Andrew. > >> > >> 2009/3/23 Andrew Clegg <[email protected]>: > >> > Hi, > >> > > >> > I'm trying to write a JAXB/JAXWS client for this service: > >> > > >> > http://www.cbs.dtu.dk/ws/SpindleP/ws_spindlep_2_0_ws0.xsd > >> > > >> > Just using wsdl2java on that URL with no extra parameters gives this > >> > error: > >> > > >> > WSDLToJava Error: Thrown by JAXB : undefined simple or complex type > >> > 'spindlep:seqlookup' > >> > > >> > ... presumably because all the types in use in that WSDL are defined > >> > in imported schemas with relative paths: > >> > > >> > <xsd:import > >> > namespace="http://www.cbs.dtu.dk/ws/ws-common" > >> > schemaLocation="../common/ws_common_1_0b.xsd" > >> > /> > >> > <xsd:import > >> > namespace="http://www.cbs.dtu.dk/ws/ws-spindlep" > >> > schemaLocation="ws_spindlep_2_0_ws0.xsd" > >> > /> > >> > > >> > ... so I tried supplying a JAXB catalog (SpindleP.cat) as described > >> > here: > >> > > >> > https://jaxb.dev.java.net/guide/Fixing_broken_references_in_schema.htm > >> >l > >> > > >> > This contains the following lines: > >> > > >> > PUBLIC "http://www.cbs.dtu.dk/ws/ws-common" > >> > "http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd" > >> > PUBLIC "http://www.cbs.dtu.dk/ws/ws-spindlep" > >> > "http://www.cbs.dtu.dk/ws/SpindleP/ws_spindlep_2_0_ws0.xsd" > >> > > >> > I know those XSD URLs work (you can check them yourself...). But when > >> > I re-ran wsdl2java like this: > >> > > >> > wsdl2java -catalog SpindleP.cat > >> > http://www.cbs.dtu.dk/ws/SpindleP/SpindleP_2_0_ws0.wsdl > >> > > >> > ... I got exactly the same error. Weirdly, even with -verbose, there's > >> > no indication that wsdl2java is trying and failing to read the > >> > imported schemas. It's as if it's completely ignoring the catalog > >> > file. > >> > > >> > Any idea what I'm doing wrong? I also tried using SYSTEM paths rather > >> > than PUBLIC in the catalog file, same result. Also tried both CXF 2.2 > >> > and 2.1.4 with no difference. > >> > > >> > I could probably contact the maintainers of that service and get them > >> > to provide a URL instead of a relative path, and for now I'll just > >> > download and modify the appropriate files myself. But it's a bit of a > >> > shame if it doesn't work as designed, especially since SoapUI just > >> > resolves the locations for me automatically. If this is unexpected > >> > behaviour, let me know and I'll JIRA it. > >> > > >> > Thanks, > >> > > >> > Andrew. > >> > > >> > -- > >> > > >> > :: http://biotext.org.uk/ :: > > > > -- > > Daniel Kulp > > [email protected] > > http://www.dankulp.com/blog -- Daniel Kulp [email protected] http://www.dankulp.com/blog
