• 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

validating SOAP Message along with the contents of SOAP Body

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the best approach to validate an incoming SOAP message in its entirety in a client? I am more concerned about validating the SOAP Body content and Header entries which are defined in a vendor's namespace by schemas created by Vendor/WebService provider.
The WebService provider may not provide an "xsi:schemaLocation" attribute for these user defined nodes in the SOAP message. So if we have content in a SOAP message that are defined in different namespaces, do we need to strip those individual nodes and validate them separately. Is there a way in any of the parsers (either thro' JAXP/SAAJ API or in a non-portable way) to say,
"validate nodes in the namespace 'A' with schema 'schemaA.xsd'"
and
"validate nodes in the namespace 'B'with schema 'schemaB.xsd'".
I hope I made it clear. I know that the JAXP API provide a way to specify "one" XML Schema for validating an XML. But more than one based on a namespace...?
Appreciate your help.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try writing an aggregate .xsd document, which would import the other schema definitions (one for each namespace).
 
S Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lasse, that is a good idea. Thanks for the tip.
What is the best practice though in the Web Service world? Getting the content nodes separately and validating or validating the whole SOAP message as is?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by S K K Kumar:
What is the best practice though in the Web Service world? Getting the content nodes separately and validating or validating the whole SOAP message as is?

Well, there's no need to validate the whole SOAP message as the envelope is guaranteed to be well-formed by the fact that the SOAP engine passes it on to your service implementation. Mostly I've skipped the "real" validation and just relied on my (application-specific) message parser to report an error if it doesn't find what it expects to find. I really don't know what is the best practice, though.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like "if it doesn't find what it expects to find". Validation also checks that there's nothing there you didn't expect. I prefer to consider that harmless if possible.
Validating with your copy of the schema checks that the provider sent nothing you didn't expect. Prevents them from adding a field for some other consumer. Validating with their copy of the schema checks that they sent you what they said they would, but does not protect you from them removing a field you really need so long as they keep the schema in sync. Neither of those sound all that good, do they?
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic