• Post Reply Bookmark Topic Watch Topic
  • New Topic

validating SOAP Message along with the contents of SOAP Body

 
S Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!