2

We have developed a simple C++ application using gSoap . When we use classical Makefile, everything is OK and the system works fine. But when we use GNU autotools as the build system, we encounter a strange constraint violation validation error when we call the service:

( SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Validation constraint violation: invalid value in element 'risk'"
Detail: [no detail]

We've checked all the compile and like flags and both look the same.

Makefile.am

ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS =  --pedantic -Wall -Wno-vla -Wno-unknown-pragmas -Wno-format
bin_PROGRAMS= Client Server
Client_SOURCES=card_soap_client.cpp  envC.cpp  stdsoap2.cpp  cardProxy.cpp  cardC.cpp
Client_CPPFLAGS= $(AM_CPPFLAGS) -DWITH_NONAMESPACES 
Server_SOURCES=card_soap_server.cpp  envC.cpp stdsoap2.cpp  cardService.cpp  cardC.cpp
Server_CPPFLAGS= $(AM_CPPFLAGS) -DWITH_NONAMESPACES 

Makefile

CF=-c -Wall --pedantic -Wno-vla -Wno-unknown-pragmas -Wno-format  -g -O2  -fPIC -DPIC -DWITH_NONAMESPACES 
LF =  -g -O2
all: card_soap_client.o card_soap_server.o cardProxy.o  cardService.o cardC.o envC.o stdsoap2.o
        g++ card_soap_client.o cardProxy.o   cardC.o envC.o stdsoap2.o   $(LF) -o Client
        g++  card_soap_server.o cardService.o  cardC.o envC.o  stdsoap2.o  $(LF) -o Server
cardC.o:cardC.cpp
        g++ $(CF) cardC.cpp
cardService.o:cardService.cpp
        g++ $(CF) cardService.cpp
cardProxy.o:cardProxy.cpp
        g++ $(CF) cardProxy.cpp
envC.o: envC.cpp
        g++ $(CF) envC.cpp
stdsoap2.o: stdsoap2.cpp
        g++ $(CF) stdsoap2.cpp
card_soap_client.o:card_soap_client.cpp
        g++ $(CF) card_soap_client.cpp
card_soap_server.o:card_soap_server.cpp
        g++ $(CF) card_soap_server.cpp

We've generated the service using 2.8.9 and 2.8.23 and compiled with g++-4.7. The service is generated with the following command:

soapcpp2  -i -n -qcard  -I/usr/share/gsoap/import/ interface_v1.3.1.hpp

UPDATE: The full source is available here

  • Did you try this on a different machine? – ZivS Sep 29 '15 at 07:48
  • How do the xml messages sent by the client(s) look like? Are they identical? – Johannes S. Sep 29 '15 at 08:37
  • @ZivS Same results here. I can reproduce same error using autotools on my machine (Debian 8.1) – sorush-r Sep 29 '15 at 12:36
  • How do I reproduce the issue? I've used `make` in `src` and did your command `soapcpp2 ...` so far. – m8mble Sep 29 '15 at 20:00
  • @m8mble run `make -f my_makefile` in `src` directory. That will generate `Client` and `Server` executables. then run `make` in toplevel directory. that will compile `AM_Client` and `AM_Server`. These programs input a port number. E.g. `Server 7000` and `Client 7000` – sorush-r Sep 29 '15 at 20:12
  • I'm sry, I can't reproduce. I did as you suggest, both with `my_makefile` and the generated one. `Server` and `Client` (as well as the `AM_`-Versions) don't say anything. Especially, they don't emit any SOAP faults. – m8mble Sep 29 '15 at 21:20

1 Answers1

2

The root of the evil is the config.h file that is generated by autoconf tools. Look at CF var of your Makefile. If you add -DHAVE_CONFIG_H -I. -I.. i.e. your CF will be

CF=-c -Wall -DHAVE_CONFIG_H -I. -I.. --pedantic -Wno-vla -Wno-unknown-pragmas -Wno-format -g -O2 -fPIC -DPIC -DWITH_NONAMESPACES

then you will have same error as at the automake variant of compilation

EDITED Look at soap_s2double function in the stdsoap2.cpp file. If we activate HAVE_CONFIG_H macros (via -DHAVE_CONFIG_H option) that it in turn deactivates HAVE_STRTOD macros (look stdsoap2.h file). As result we have SOAP_TYPE error (because we can't convert string value of the risk var to double). If we work without HAVE_CONFIG_H macros that we have HAVE_STRTOD active macros and therefore strtod function works succesfully and we don't have any error.

EDITED N1

If you add #define HAVE_STRTOD 1 string to your config.h file then all will work perfectly.

Oleg Gopkolov
  • 1,684
  • 10
  • 17
  • Now we get closer a bit! So what is CF? and why adding more include directories will cause a validation error? – sorush-r Sep 29 '15 at 20:13
  • `CF` is a variable containing compiler flags. Adding includes doesn't change much (as long as it still compiles). Also `PIC` not relevant for you (only for dlls). I'd guess the `HAVE_CONFIG_H` changes a lot (cf. `src/stdsoap2.h` lines 197ff). But I can't verify it's the reason of your problems yet... – m8mble Sep 29 '15 at 21:39
  • @OlegGopkolov Thanks. – sorush-r Sep 30 '15 at 05:16
  • @sorush-r You are welcome. Please, see......... I've edited my answer once again. – Oleg Gopkolov Sep 30 '15 at 09:39
  • That is great answer! I am developing a library with gsoap and according to the manuals, we should compile stdsoap2.cpp with `-DWITH_NONAMESPACES`. It turns out that `HAVE_STRTOD` (and other settings) are messing up everything. I just copied the line `AC_CHECK_FUNCS` from gsoap `configure.ac` to my `configure.ac` and that helped. When trying samples I always used compiled library `-lgsoap++`, which has stdsoap2.cpp compiled as it should have been. – nobody Nov 18 '22 at 10:37