IBM WebSphere DataPower Community Forum IBM Webspere DataPower XI50
October 12, 2008, 03:27:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: IBM WebSphere DataPower SOA Appliance Forum - Just Launched come share your knowledge!!! These forums will be a great place to build a community. This site is not associated with IBM.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: XSD schema validation  (Read 576 times)
bburridg
Newbie
*
Offline Offline

Posts: 1


View Profile
« on: November 20, 2007, 02:04:48 PM »

I am working in a DataPower environment and currently when an XML request is validated against an XSD and it fails, we have no way of reporting back to the client what the error was (in the reply that is). Do you know of any way to do this?

Brian
Logged
LordB
Administrator
Newbie
*****
Offline Offline

Posts: 45


View Profile
« Reply #1 on: November 20, 2007, 02:34:11 PM »

If you create an error rule with an tranformation action with the xslt that looks something like the following I think you will get more of what you are looking for...


Quote
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig">
  <xsl:output method="xml" version="1.0" />
   <xsl:template match="/*[local-name()='Envelope']/*[local-name()='Body']/*">
   <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
     <env:Fault>
      <faultcode>env:Client</faultcode>
      <faultstring>
       <xsl:copy-of select="dp:variable('var://service/error-message')" />
      </faultstring>
    </env:Fault>
   </env:Body>
  </env:Envelope>
 </xsl:template>
</xsl:stylesheet>
Logged
SimoneP
Newbie
*
Offline Offline

Posts: 2


View Profile
« Reply #2 on: November 27, 2007, 10:01:35 AM »

Thanks for posting the suggestion to use the XSLT script. 

I have tried it and I have found that var://service/error-message does not actually contain the XSD validation error.

For instance, in my test, the log shows the following error:

xmlfirewall (XXXX): Schema Validation Error
xmlfirewall (XXXX): Execution of 'local:///XXXX.xsd' aborted: http://dynamic:80/XXXXX: cvc-particle 2.1: in element {http://www.XXXX}Foo with anonymous type, found <wms:FooBar> (in namespace http://www.XXXX), but next item should be {http://www.XXXX}Bar

But when I go in the probe and I check the context information right after the validation, the var://service/error-message contains

'<?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>Internal Error (from client)</faultstring></env:Fault></env:Body></env:Envelope>'

I think that in order to capture the error, we may need to use the schema-validate extension function.  The documentation does not make it clear that it should return the error, but it's worth a try...  The documentation says that the function returns the validated node-set but it's possible that in case of failure it would return the error...  I haven't tried that though.


Logged
SimoneP
Newbie
*
Offline Offline

Posts: 2


View Profile
« Reply #3 on: November 27, 2007, 11:27:37 AM »

So I went ahead and tried using the extension function (I'm validating the entire input message):

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig">

  <xsl:output method="xml" version="1.0" />
   <xsl:template match="/">
     <xsl:variable name="input">
         <xsl:copy-of select="dp:variable('var://context/INPUT')"/>
     </xsl:variable>
     
     <xsl:variable name="output">
         <xsl:copy-of select="dp:schema-validate('local:///myschema.xsd', $input)" />
     </xsl:variable>

     <xsl:copy-of select="$output"/>

     <xsl:if test="$output=''">
        <dp:reject override="true">Schema validation error detected</dp:reject>
        <dp:set-variable name="'var://service/error-subcode'" value="0x80c00010"/>
     </xsl:if>
   </xsl:template>
</xsl:stylesheet>

Note that the full error text containing the reason for the validation error is displayed in the log, but NEVER is set in any of the service error variables.  The best I could do is check whether the input node-set to schema-validate was returned back - if not, it's an error...
Logged
ihashim
Newbie
*
Offline Offline

Posts: 1


View Profile
« Reply #4 on: June 06, 2008, 12:36:42 AM »

We are experiencing the same error and don’t know what it means. Can you please tell us what was wrong and how you fixed it. At least get us going in the right direction. Any help with this will be greatly appreciated.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Seo4Smf © Webmaster's Talks
This Site is not associated with IBM