• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
is.setEncoding("UTF-8");
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
SaxHandler handler = new SaxHandler();
parser.parse(is, handler);
return handler.subscriptionId;
} catch (Exception e) {
e.printStackTrace();
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?
thanks
Max
 
reply
    Bookmark Topic Watch Topic
  • New Topic