Reasons pub.schema:validate always returns true

After reading about a 1/2 dozen posts from people indicating that their validate service always returns true and not finding any answers I decided to test it myself see what I could come up with (ok, so i had the same problem and was actually just trying to resolve it).

I’ve found that the following two scenarios cause the pub.schema:validate service to always return true (IS 6.1):

  1. Make sure your xmlData input begins with the header “<?xml version="1.0"?>”. If you pass in an XML Node without the header the service always returnes true. I ran into this problem because I was calling soap.util:getBody service and passing that XML Node into the validate service. I had to add a MAP step to append the xml version tag to make the validate service work properly.

  2. If your XSD file defines a target namespace, make sure the XML root node you’re validating is prefixed and declares the same namespace. If it’s prefixed and declares the wrong namespace, the service returns an error, which is OK. If it has no prefix or namespace, for example:

[highlight=xml]

<?xml version="1.0"?> 123 34sdf sdf2 [/highlight] but the XSD Schema declares a namespace the service returns true. I would have expected the validate service to return a "Unable to locate a matching element declaration" as it does if you specify the wrong namespace.

Hope this helps and if anyone can explain this behavior, or a mistake that I’ve made please do!

Fred

that is quite useful

I don’t think if tagged my XML sample properly above so here goes again. My original posting above should have read:

  1. If your XSD file defines a target namespace, make sure the XML root node you’re validating is prefixed and declares the same namespace. If it’s prefixed and declares the wrong namespace, the service returns an error, which is OK. If it has no prefix or namespace, for example:
<?xml version="1.0"?>
<myServiceInput>
  <field1>123</field1>
  <field2>34sdf</field2>
  <field2>34sdf</field2>
  <field3>sdf2</field3>
  <field4>123</field4>
  <field5>true</field5>
</myServiceInput>

but the XSD Schema does declare a namespace the service returns true. I would have expected the validate service to return a “Unable to locate a matching element declaration” as it does if you specify the wrong namespace.

hi,

i faced the same issue on my project as well and can confirm the behaviour as described. cause of our generic solution we were not able to ensure that the XML root node is prefixed. but we solved that issue by validating data against document instead of xml schema. that document was created directly from the same xsd file as the schema. and seems that the service pub.schema:validate is working properly.

jan

Hi All

I have IS schema for above xml schema , while doing testing I passed xml as below mention(with out field tags) but the service return isValid value true where I expected some error.

<?xml version="1.0"?>

Please let me know how to validate the xml tags in particular place by using IS schema.
Regards,
Varma

Hi

I have created IS schema for the

<?xml version="1.0"?> 123 34sdf 34sdf sdf2 123 true

while testing I passed the below xml , I have set pub.schema:validate conformTo which I created IS schema ns but validate gave isValid valu true where i was expected some error because i am not passing field tags in input xml.

<?xml version="1.0"?>

Please let me know solve this problem.

In your xsd are those fields are set to mandatory minoccurs=1?? then only the validate functionality works.Please check this in your schema.

HTH,
RMG

Thanks a lot RMG

Regards,
Varma

Hi All,

I have a scenario where in i have defined an element as Required=true, Allow null=false. I generated webMethods schema using an xsd and when i validate an xml where i remove the value of that field (passing null i.e empty tag), the schema deosn’t throw any error. But ideally it should throw validation fail error, because the field is having allow null as false. Can any one throw some thought on this.

Thanks,
KK

Can you provide an sample XSD and a document you’re attempting to validate. This functionality works as expected in IS 6.5.

Mark

HI Mark,

Please find the XSD i used to create webM schema and xml which i am using to verify against the schema. I did not pass any value in a mandatory tag (MSISDN) and even then schema deosn’t throws any error.

Thansk,
KK
2011_Raj_Changed_To Reflect_IDD.xsd (2.97 KB)
2011_css.xml (964 Bytes)

I am doing pub.schema:validate againt OAGS schema for SyncCatalog. Here is the sample data I am using.

<?xml version="1.0"?>

<ns:SyncCatalog
xmlns:ns=“http://openapplications.org/oagis/9”>
ns:ApplicationArea
ns:CreationDateTime2009-01-15 12:42:29+00:00</ns:CreationDateTime>
</ns:ApplicationArea>
</ns:SyncCatalog>

I am getting [ISC.0082.9003] Unable to locate a matching element declaration error for all the 3 nodes in this data. I am using webMethods 6.5. Any help is appreciated.

Thanks