Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Loading schemas from WSDL documents
Loading schemas from WSDL documents [message #563964] Tue, 10 December 2002 16:50
Eclipse UserFriend
Originally posted by: carman.itc.it

G'day!

I have been attempting to use the excellent xsd project to access schema
type definitions within WSDL (Web Service Description Language) documents.

But have thus far been unable to load them. Is there an easy way to do
this?

At first I tried to load the documents as if they were straight xsd
documents by adding "wsdl" to the Extension-to-Factory-Mapping:


Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "wsdl",
new XSDResourceFactoryImpl());

That didn't work, (and probably it wasn't supposed to?), so I decided to
use a DOM parser on the original document, find the <xsd:schema> element
and pass that to xsd using the XSDSchema.setElement(org.w3c.dom.Element)
method. That should work, right?

Using the EMF/XSD build from 20021023, the code (attached to the end of
this message), runs without raising an exception, but doesn't seem to load
the schema properly, (I can't access the type definitions that should be
in it).

Using the build from 20021127, the code returns an exception:
java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 02)
....
when executing the setElement() command.

I am using xsd/emf in stand-alone mode (from outside of eclipse). Have I
forgotten to do something, or is there a bug here?

Please forgive me if I have missed something obvious!
Thanks a lot for your help,

Mark Carman
PhD Student
ITC-irst


********** The Code **************************************

import org.w3c.dom.*;
import org.eclipse.xsd.*;

public class Test {

public static void main(String args[]) {

// required proxy settings to access internet
java.util.Properties props = System.getProperties();
props.put("http.proxyHost","wwwproxy");
props.put("http.proxyPort","80");

try {

// load WSDL document into DOM
String wsdlURL =
"http://live.capescience.com/wsdl/GlobalWeather.wsdl";
Document doc =
javax.xml.parsers.DocumentBuilderFactory.newInstance().newDo cumentBuilder().parse(wsdlURL);

// get <schema> element from inside <types> declaration
Element schemaElement = (Element) ((Element)
doc.getDocumentElement().getElementsByTagName("types").item(0)).getElementsByTagName( "xsd:schema").item(0);

// create new schema object and use the setElement method to load
the DOM description into it
XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
schema.setElement(schemaElement);

// print out the schema
System.out.println(schema.toString());

}
catch (Exception e) {
e.printStackTrace();
}

}

}

********* The Error Message ****************************
java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 02)
at
org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:704)
at
org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:1935)
at
org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1444)
at
org.eclipse.xsd.impl.XSDSchemaImpl.traverseToRootForPatching (XSDSchemaImpl.java:1436)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.changeAttribut e(XSDConcreteComponentImpl.java:1211)
at
org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2147)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1182)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.setElementGen( XSDConcreteComponentImpl.java:2768)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.setElement(XSD ConcreteComponentImpl.java:2800)
at
org.eclipse.xsd.impl.XSDSchemaImpl.setElement(XSDSchemaImpl. java:2274)
at Test.main(Test.java:23)
java.lang.NullPointerException
at
org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1447)
at
org.eclipse.xsd.impl.XSDSchemaImpl.traverseToRootForPatching (XSDSchemaImpl.java:1436)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.changeAttribut e(XSDConcreteComponentImpl.java:1211)
at
org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2147)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1182)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.setElementGen( XSDConcreteComponentImpl.java:2768)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.setElement(XSD ConcreteComponentImpl.java:2800)
at
org.eclipse.xsd.impl.XSDSchemaImpl.setElement(XSDSchemaImpl. java:2274)
at Test.main(Test.java:23)
Previous Topic:UML diagram in the JavaDoc of the XSD project
Next Topic:Loading schemas from WSDL documents
Goto Forum:
  


Current Time: Fri Apr 26 12:56:37 GMT 2024

Powered by FUDForum. Page generated in 0.03491 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top