gSOAP and types

Tuesday, October 20th, 2009 | General

Well I had this problem and I thought I’d write a quick post about it because I couldn’t find anything useful on the Internet. It took me in depth debugging to resolve the issue. The issue was, I was getting this error in TEST.log: “Validation constraint violation: data type mismatch in element ‘id’” where my id tag was defined as an xsd:long. This had an internal type in gsoap of LONG64.

So, what the heck was the problem? I fiddled with a custom typemap.dat and made sure the xsd__long was defined as an int64_t (‘cos it is on my platform) and I even found some suggestions on the Internet to use “-e” when compiling using soapcpp2. Nada.

That’s when I started debugging gSOAP – as I have been doing continuously the last two weeks – and I traced the problem all the way back to a function inside stdsoap2.cpp called “soap_s2LONG64″. This function is responsible for string to long conversion. Now the first thing I noticed is that it’s possible for the entire function to be completely empty because almost all of it is conditional with a lot of #ifdefs. I double checked this by having a look at my compiled assembly and sure enough it was completely empty. There was no way for this function to ever succeed.

What had I done wrong? Well I had included the gsoap code directly into my build – my makefile – and I wasn’t building it as a separate library. What I had failed to notice though is that the stdsoap2.h needs config.h to determine which functions are available on the system. Some of these functions are the very ones used within soap_s2LONG64. Since there was no detection and definition of the defines, there was no real body to the function. That’s why it was happening.

Of course, I just added the checks into autoconf and made sure that stdsoap2.h’s include directive for the config.h file was pointing to the right place. Viola. It was working like a charm.

In summary: If you’ve included stdsoap2.cpp into your build, then you need to define which string to long conversion functions are in your system. You can do with this with your compilation command (g++ -DHAVE_STRTOLL) or define it just before you include stdsoap2.h in your code. Of course, autoconf makes it a lot easier. It’s up to the build system you’re using. If you’re doing it manually, try defining HAVE_STRTOLL or HAVE_SSCANF.

2 Comments to gSOAP and types

Yahya
July 26, 2010

Dear;

I think I have the same problem but I don’t know what to do and I’m working on Visual Studio so I can use the GCC compiler

Can you please help me

durand
July 26, 2010

I’m not too sure about Visual Studio but in gsoap there’s a collection of conditional defines:

#ifdef HAVE_CONFIG_H
# include “config.h”
# ……… snip ………..
#else
# if defined(UNDER_CE)
# ………….. snip ……….
# elif defined(WIN32)
# ……….. snip ………….

So, I guess you would just want to make sure that WIN32 is defined in your build. In the case of Visual Studio, I would imagine that this is done automatically.

Leave a comment