jQuery in Action, 2nd edition*
The moose likes XML and Related Technologies and the fly likes How DO I Set XSDs in a web app for a Sax Parser? 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 "How DO I Set XSDs in a web app for a Sax Parser? " Watch "How DO I Set XSDs in a web app for a Sax Parser? " New topic

How DO I Set XSDs in a web app for a Sax Parser?

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 365
Hi All-

I'm running into an xml validation issue calling a web service using HttpURLConnection in a servlet.
I get a good response, with a soap envelope, and I want to parse the xml.

I get a Malformed URL error (no protocol) due to missing schemas.

the response string ( a few field names changed to protect the innocent): the main point is to show the schemas involved

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body xmlns:ns1="http://docs.oasis-open.org/wsn/bw-2"><SubscribeResponse xmlns="http://docs.oasis-open.org/wsn/b-2"><SubscriptionReference xmlns="http://docs.oasis-open.org/wsn/b-2"><Address xmlns="http://www.w3.org/2005/08/addressing">https://w02777/orion/soap?ServiceName=NotificationProducer</Address><ReferenceParameters xsi:type="ns:FooReferenceParametersType" xmlns:ns="http://www.foo.com/ws/integration/notification/2008/10" xmlns="http://www.w3.org/2005/08/addressing"><SubscriptionId xmlns="http://www.foo.com/ws/integration/notification/2008/10">TCSN_foo_Subscriber_331DAA98-4DC7-11DF-836B-AE4F0AC5625E</SubscriptionId></ReferenceParameters></SubscriptionReference></SubscribeResponse></soap:Body></soap:Envelope>

my code:

String getSubscriptionIdFromResponse(String response) {
InputSource is = new InputSource(response);
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
SaxHandler handler = new SaxHandler();
parser.parse(is, handler);
return handler.subscriptionId;
} catch (Exception e) {
return "error occurred";


The xml is received as a repsonse:
I have the missing XSDs (the "docs oasis" ones and one application XSD).

My question: where do I put them so the parser will resolve them? web-inf doesn't work.
Also, do I have to resolve the xsi mapping with their new location?

any ideas?
GeeCON Prague 2014
subject: How DO I Set XSDs in a web app for a Sax Parser?