Discussion:
How to use gSOAP to validate xml against xsd
f***@public.gmane.org
2013-11-15 10:01:38 UTC
Permalink
I'm facing the following problem concerning xml validation with gSOAP:
I use wsdl2h to generate a header file from my xsd and soapcpp2 to generate C sources from that header file. Using the generated sources in my program I'm able to write an xml file.
Is there any way to validate the generated xml file against the xsd after/during generation?
Thanks, Florian
Tony Ray Pierce
2013-11-17 12:55:56 UTC
Permalink
You can use a tool like SOAPUI. In it, you can create a “project” by importing your XSD. Then you can use it to generate a request, which you can then validate using a function of the tool.

Tony
Post by f***@public.gmane.org
I use wsdl2h to generate a header file from my xsd and soapcpp2 to generate C sources from that header file. Using the generated sources in my program I'm able to write an xml file.
Is there any way to validate the generated xml file against the xsd after/during generation?
Thanks, Florian
s***@public.gmane.org
2013-11-15 10:27:10 UTC
Permalink
I'm facing the following problem concerning xml validation with gSOAP:
I use wsdl2h to generate a header file from my xsd and soapcpp2 to generate C sources from that header file.



Using the generated sources in my program I'm able to write an xml file, and sadly I'am able to write a xml file which is not valid against the original schema.
Is there any way to validate the generated xml file against the xsd after/during generation with the help of gsoap? Or do I have to use a seperate validator?



Thank you very much in advance,

Sebastian
Abebe Hailu
2013-11-17 20:17:22 UTC
Permalink
Hallo Florian,

to enforce strict validation of the xml-messages during generation you can
set the following flag in your c code after soapinit:

soap_set_imode(&soap, SOAP_XML_STRICT);

don't forget -s option in soapcpp2 this will generate a deserialization code
with strice xml validation check.

best regard

Abebe
Post by f***@public.gmane.org
I use wsdl2h to generate a header file from my xsd and soapcpp2 to
generate C sources from that header file.
Using the generated sources in my program I'm able to write an xml file,
and sadly I'am able to write a xml file which is not valid against the
original schema.
Is there any way to validate the generated xml file against the xsd
after/during generation with the help of gsoap? Or do I have to use a
seperate validator?
Thank you very much in advance,
Sebastian
f***@public.gmane.org
2013-11-18 10:17:27 UTC
Permalink
My .h file contains constraint annotation like <minOccurs>:<maxOccurs> as described in http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc17 http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc17 and I am using soapcpp2 with -s flag. Although I use soap_set_imode(&soap, SOAP_XML_STRICT); in my code I am still able to generate an xml file that does not fit the .xsd file without getting any error. Shouldn't there appear one of the error codes mentioned in http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc10.2 http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc10.2 ?


---In ***@yahoogroups.com, <***@...> wrote:

Hallo Florian,

to enforce strict validation of the xml-messages during generation you can set the following flag in your c code after soapinit:


soap_set_imode(&soap, SOAP_XML_STRICT);


don't forget -s option in soapcpp2 this will generate a deserialization code with strice xml validation check.


best regard


Abebe









On Fri, Nov 15, 2013 at 11:27 AM, <***@... mailto:***@...> wrote:
I'm facing the following problem concerning xml validation with gSOAP:
I use wsdl2h to generate a header file from my xsd and soapcpp2 to generate C sources from that header file.




Using the generated sources in my program I'm able to write an xml file, and sadly I'am able to write a xml file which is not valid against the original schema.
Is there any way to validate the generated xml file against the xsd after/during generation with the help of gsoap? Or do I have to use a seperate validator?



Thank you very much in advance,

Sebastian

Loading...