Using the WSDL Validator Outside of Eclipse
WTP's WSDL validator validates WSDL 1.1 documents against the WSDL 1.1 specification. Through the Web Services Interoperability (WS-I) extension it can also validate against the WS-I Basic Profile 1.1, Simple SOAP Binding Profile 1.0 and Attachments Profile 1.0.
The WSDL validator, available in all WTP downloads, is located in plug-in org.eclipse.wst.wsdl.validation. The current version of the WSDL validator will only compile against Eclipse 3.2, WTP 1.5 and later. If you'd like to compile the validator with an older version of Eclipse or outside of Eclipse you should be able to by removing the package org.eclipse.wst.wsdl.validation.internal.eclipse, which contains all of the Eclipse and WTP dependencies. You may also have to make changes to the manifest if it causes you problems.
Validating WSDL Documents Programmatically
The WSDL validator can be used programmatically both within and outside of Eclipse.
Prerequisite to using the WSDL validator programmatically
The WSDL validator has a prerequisite to validating WSDL 1.1 documents: It must be able to locate the WSDL 1.1 schemas (WSDL, SOAP, HTTP, MIME). The WSDL validator provides the method
public void addURIResolver(IExtensibleURIResolver uriResolver)
Using this method you can add a resolver to locate the schemas. The resolver can be as simple as a pointer to the local or remote location of the schemas or can be more complex such as the URI resolution framework included in WTP. An example URI resolver that wraps the WTP URI resolution framework and registers it with the WSDL validator can be seen here.
Invoking WSDL validation
WSDL validation can be invoked as follows
WSDLValidator validator = new WSDLValidator();
IValidationReport report = validator.validate(URI, INPUTSTREAM, CONFIGURATION);
The URI is actually a URL location representing the location of the document. The WSDL validator won't read from this location if an INPUTSTREAM is provided.
The INPUTSTREAM is an optional inputstream that represents the URI location.
The CONFIGURATION is a WSDLValidationConfiguration, which can be used to pass properties to the validator and extension validators.
The validator returns an IValidationReport that contains validation messages (errors and warnings) produced during validation.
Registering additional WSDL 1.1 validators
The WSDLValidator also provides the method
public void registerWSDL11Validator(String namespace, WSDL11ValidatorDelegate delegate)
which allows you to register a validator for an extension WSDL 1.1 namespace. Validators for HTTP 1.1 GET and POST and SOAP 1.1 are already provided. When working outside of Eclipse you'll likely want to create a ClassloaderWSDL11ValidatorDelegate as follows:
WSDL11ValidatorDelegate delegate = new ClassloaderWSDL11ValidatorDelegate("org.example.extension.WSDLValidator");
Note: As of WTP 1.5, the classes discussed in this section have not been declared as API and are therefore subject to change.