aspose file tools*
The moose likes XML and Related Technologies and the fly likes WSDL Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "WSDL Validation" Watch "WSDL Validation" New topic
Author

WSDL Validation

Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Can anybody tell me whether one can validate an WSDL file..if so where can I find the WSDL schema that I can use for validation & also please suggest any good WSDL websites I could go to.
Thanks,
Roopa
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi again Roopa,
By using the same code you submitted earlier
The schema location is:
http://schemas.xmlsoap.org/wsdl/
Hope this helps
[ December 16, 2002: Message edited by: Beno�t d'Oncieu ]
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Thanks a lot again Beno�t d'Oncieu. I appreciate ur quick & very helpful responses.
Roopa
Originally posted by Beno�t d'Oncieu:
Hi again Roopa,
By using the same code you submitted earlier
The schema location is:
http://schemas.xmlsoap.org/wsdl/
Hope this helps
[ December 16, 2002: Message edited by: Beno�t d'Oncieu ]
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Do I have to change the code to the following to validate an WSDL file?
static final String WSDL_SOURCE =
"http://schemas.xmlsoap.org/wsdl/";
saxParser.setProperty(WSDL_SOURCE, new File("c:/projects/WSDLSchema.xsd"));

I did make the above change & the exception I get is
org.xml.sax.SAXNotRecognizedException: http://schemas.xmlsoap.org/wsdl/
Originally posted by Beno�t d'Oncieu:
Hi again Roopa,
By using the same code you submitted earlier
The schema location is:
http://schemas.xmlsoap.org/wsdl/
Hope this helps
[ December 16, 2002: Message edited by: Beno�t d'Oncieu ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have been a bit fast on the reply and while trying to give you the exact code, I did realise it was a bit more complex that what I initially expected :roll:
I'll come back later with some code
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I think I have it right now. Look at the main method to see how to use it. It's really a first attempt (using Xerces), but it still needs improving.
If your wsdl is using more namespaces, you can register them using the registerNamespace method before calling the validateSchema.
I also removed the verbose stuff for the ErrorHandler for the sake of simplicity
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
awsome...Thanks
BTW are u using Xerces 2.2.1. Have u tried using this parser to validate xml schemas too?
Thanks,
Roopa
Originally posted by Beno�t d'Oncieu:
I think I have it right now. Look at the main method to see how to use it. It's really a first attempt (using Xerces), but it still needs improving.
If your wsdl is using more namespaces, you can register them using the registerNamespace method before calling the validateSchema.
I also removed the verbose stuff for the ErrorHandler for the sake of simplicity
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Roopa,
Correct, I am using Xerces 2.2.1.
The code I submitted before is exactly doing validation of a WSDL file. A WSDL file is actually a XML schema
Because you mentionned validating a WSDL file, I have added the WSDL and SOAP grammars before parsing for the WSDL file to be correctly validated.
Complete validation of a WSDL file would require a bit more work to be acurate, as I'm not validating inside attribute values, though they might contain reference to other grammars (via namespaces).
Regards
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Roopa Bagur:
Can anybody tell me whether one can validate an WSDL file..if so where can I find the WSDL schema that I can use for validation & also please suggest any good WSDL websites I could go to.
Thanks,
Roopa

MAy be this article give u some guide http://www.fawcette.com/xmlmag/2002_07/online/webservices_rjennings_07_08_02/


Spritle Software Blogs
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Balaji,
Nice link, however, most ideas from the article can only be applied when using Microsoft .NET
Thanks
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Can u validate the following schema against W3C schema(http://www.w3.org/2001/XMLSchema.xsd).I used Xerces SAX parser & am still stepping into problems..
Here is my schema file:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.53.com/b2b/reports"
xmlns="http://www.53.com/b2b/reports"
xmlns:b2b="http://www.53.com/b2b/messaging">
<xsd:complexType name="GetReportMetaDataRequest">
<xsd:annotation>
<xsd ocumentation>A GetReportMetaDataRequest contains the request for a message to
get the meta-data for series of reports.</xsd ocumentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="reportCode" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd ocumentation>The report codes of the reports whose meta-data are being requested. If no
report codes are specified, the meta-data for all reports will be returned.</xsd ocumentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:element>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="12"/>
</xsd:restriction>
</xsd:element>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Thanks a lot,
Roopa
Originally posted by Beno�t d'Oncieu:
Balaji,
Nice link, however, most ideas from the article can only be applied when using Microsoft .NET
Thanks
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Ropa,
Here is the result of the validation of your XML Schema:

I had to change a bit the code to adapt it to schema validation (as opposed to WSDL validation). Here it goes:

Cheers
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Guess what... I am using the exact same code & I get the following error..There is no meta element in my schema or in the w3c schema.......... I am sorry to keep bugging you & I really appreciate your patience ....
[Error] XMLSchema.xsd:6:20: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than x
s:appinfo and xs ocumentation. Saw 'web_redirect'.
[Fatal Error] XMLSchema.xsd:8:3: The element type "meta" must be terminated by the matching end-tag "</meta>".
::http://www.w3.org/2001/XMLSchema.xsd:http://www.w3.org/2001/XMLSchema.xsd:http://www.w3.org/2001/XMLSchema.xsd:8:3:The
element type "meta" must be terminated by the matching end-tag "</meta>".
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchema(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.parsers.XMLGrammarPreparser.preparseGrammar(Unknown Source)
at com.fifththird.b2b.messaging.compiler.MessageCompiler.<init>(MessageCompiler.java:343)
at com.fifththird.b2b.messaging.compiler.MessageCompilerFrame.butCompileActionPerformed(MessageCompilerFrame.jav
a:470)
Originally posted by Beno�t d'Oncieu:
Hi Ropa,
Here is the result of the validation of your XML Schema:

I had to change a bit the code to adapt it to schema validation (as opposed to WSDL validation). Here it goes:

Cheers
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You may be using a transparent proxy, i.e. no direct access to the web resource. In that case, I suggest you store the XMLSchema locally and then replace the line:

by:

Other than that, the following line shows a package that does not exist in Xerces 2.2.1:

This shouldn't be the cause of your problem, but if you absolutely need to use version 2.2.1, try to see if there is no version conflict between you jar files.
Cheers
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
I am using the following path for the schemaURILocation & I get an error...I have the schema file in this location but still an error.. Am I doing something wrong with the path?
protected static final String XMLSCHEMA_URI_LOCATION = "c:\\projects\\xml messaging\\bin\\XMLSchema.xsd";

[Error] :-1:-1: schema_reference.4: Failed to read schema document 'c:\projects\xml messaging\bin\XMLSchema.xsd', becaus
e 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:sch
ema>.
**********input file abs path:C:\Projects\B2B Client\Shared\Reports\bin\ReportsTypes.xsd
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(URL.java:586)
at java.net.URL.<init>(URL.java:476)
at java.net.URL.<init>(URL.java:425)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at com.fifththird.b2b.messaging.compiler.MessageCompiler.validateSchema(MessageCompiler.java:693)
at com.fifththird.b2b.messaging.compiler.MessageCompilerFrame.butCompileActionPerformed(MessageCompilerFrame.jav
Originally posted by Beno�t d'Oncieu:
You may be using a transparent proxy, i.e. no direct access to the web resource. In that case, I suggest you store the XMLSchema locally and then replace the line:

by:

Other than that, the following line shows a package that does not exist in Xerces 2.2.1:

This shouldn't be the cause of your problem, but if you absolutely need to use version 2.2.1, try to see if there is no version conflict between you jar files.
Cheers
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
OK, for this one, you'll have to find it by yourself ;-)
The exception say: MalformedURLException
You have to write the location of the XML Schema as a URL (hint: the protocol is file).
Good luck
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
ok.. After some reasearch I tried the following out
protected static final String XMLSCHEMA_URI_LOCATION = "file://C:/Projects/xml messaging/bin/XMLSchema.xsd";
Now I don't get the errors I used to get before but looks like the XMLSchema.xsd has problems.. BTW I had to remove the DOCType from the schema not validate against a DTD.
And also I had to copy xml.xsd locally ...& I point to it in the same URL format I have above..

My current errors..
[Error] XMLSchema.xsd:26:124: s4s-att-invalid-value: Invalid attribute value for 'schemaLocation' in element 'import': c
vc-datatype-valid.1.2.1.
[Error] XMLSchema.xsd:163:36: src-resolve: Cannot resolve the name 'xml:lang' to a(n) attribute declaration component.
[Error] XMLSchema.xsd:163:36: src-ct.0.1: Complex Type Definition Representation Error for type '#AnonType_schema'. Ele
ment 'attribute' is invalid, misplaced, or occurs too often.
[Error] XMLSchema.xsd:1178:34: src-ct.0.1: Complex Type Definition Representation Error for type '#AnonType_documentatio
n'. Element 'attribute' is invalid, misplaced, or occurs too often.
Originally posted by Beno�t d'Oncieu:
OK, for this one, you'll have to find it by yourself ;-)
The exception say: MalformedURLException
You have to write the location of the XML Schema as a URL (hint: the protocol is file).
Good luck
 
Consider Paul's rocket mass heater.
 
subject: WSDL Validation