cancel
Showing results for 
Search instead for 
Did you mean: 

XML Validation with XSD in java mapping

Former Member
0 Kudos

Hi experts,

I have created an interface to send differents messages between bussines system, the bussiness system receiver is put in the message, to get this value I have a configuration file indicating the path of this field for each message type. In a java mapping I transform the message sent in this structure:

<document>

<message>HERE THE MESSAGE AS STRING</message>

<parameters>

<sender>HERE SENDER BUSSINESS SYSTEM</sender>

<receiver>HERE RECEIVER BUSSINESS SYSTEM</receiver>

</parameters>

</document>

the messaging interface works fine, but now I have to validate the XML vs XSD. I need doing in a java mapping because the messaging interface send the message and a email to sender in error case.

To do this validation I have implemented two java mappings that works fine in my local, the first way is with class Validator of java 5, but my system PI 7.1 return an error with this class. The second way is with SAX parse:

String schema = "XXXXXxsd";

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

docBuilderFactory.setNamespaceAware(true);

docBuilderFactory.setValidating(true);

docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema");

InputStream is = this.getClass().getClassLoader().getResourceAsStream(schema);

docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",is);

in my local works fine but in PI always return OK never fail.

For this moment the schema is hardcoded to do proofs, in the future will be loaded from my configuration file.

Any idea?

Thanks in advance

Jose

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member206760
Active Contributor
0 Kudos

hi Jose,

PI 7.1 has a built in feature available called XML vaidations ..

your source xml can be validated against a XSD placed at a specific location on the PI server..

validation can be performed at adapter/integration engine

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d06dff94-9913-2b10-6f82-9717d9f83...

Former Member
0 Kudos

Have you tried Adapter enhancement?

You can write a module and deploy in PI where you perform all XML validations and if found invalid create a target structure capturing those errors

Regards

Sourabh