I have committed some code to support reading WSDL from other formats such
as a DOM Element or Document. Please post any comments or feedback.

I did not want to simply add to the WSDLReader interface WSDL4J-like
methods such as readWSDL(String, Element) or readWSDL(String, Document)
because this would make the WSDLReader API
depending on DOM .... which defeats one of Woden's objectives for
supporting choice of XML parser and XML object model.

One option was to capture these methods in a DOM-specific Woden API ...
like an API subset, but this suggests making parts of the overall Woden API
optional to implementors (i.e. to a StAX implementor) and this approach
probably requires more thought and discussion than I had time for right
now.

Instead I have create a container or wrapper class called
org.apache.woden.WSDLSource which simply takes in its ctor some Object
representing the WSDL source and returns this Object via a public method
getSource().   Two new readWSDL methods are added to WSDLReader ...
readWSDL(String, WSDLSource) and readWSDL(String, WSDLSource,
ErrorHandler).  The String is the uri of the base WSDL document.  See the
Javadoc comments for WSDLSource and the two readWSDL methods for more
details.

WSDLSource trades type safety for flexibility. The WSDLReader
implementation (currently just DOMWSDLReader) will throw a WSDLException if
it does not recognize the type of object contained in WSDLSource.

WSDLSource keeps the WSDLReader API independent of any particular XML
parser or XML API. I will give more thought to how to create a WSDLSource
and/or how to represent specific formats within in. There may be some role
the WSDLFactory can play here, in creating a WSDLSource subtype appropriate
to the concrete WSDLReader or something. For now (M5), WSDLSource just
solves the immediate need for reading WSDL from DOM elements or documents
without 'polluting' the Woden API with DOM-specific stuff.

The programming model looks like this:

 //String wsdlLoc =
"http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/CreditCardFaults-1G/use-credit-card-faults.wsdl";;
 String wsdlLoc =
"C:/workspace/wsdl20/woden_jktest/resources/reservation.wsdl";

 URL url = StringUtils.getURL(null, wsdlLoc); //Woden StringUtils class
 String wsdlURL = url.toString();
 DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
 dbFactory.setNamespaceAware(true);
 DocumentBuilder builder = dbFactory.newDocumentBuilder();
 Document doc = builder.parse(new InputSource(wsdlURL));

 WSDLFactory factory = WSDLFactory.newInstance();
 WSDLReader reader = factory.newWSDLReader();
 DescriptionElement desc = reader.readWSDL(wsdlLoc, new WSDLSource(doc));

I will update the two related JIRAs.

regards,
John Kaputin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to