gsoap时间戳格式以及gzip压缩问题

来源:互联网 发布:ktv调音软件下载 编辑:程序博客网 时间:2024/04/28 19:59
问题一


gsoap处理xml时间戳时,总是类似以2011-09-26T11:00:23Z的格式输出,这种时间戳表示为服务器所在地时区时间,如果面向其他时区提供服务,该格式就不能满足需要了。而需求往往是返回数据库或文本中的原时间。


解决办法:新增config.h文件


#  define HAVE_POLL
#  define HAVE_SNPRINTF
#  define HAVE_STRRCHR
#  define HAVE_STRTOD
#  define HAVE_SSCANF
#  define HAVE_STRTOD_L
#  define HAVE_SSCANF_L
#  define HAVE_SPRINTF_L
#  define HAVE_STRTOL
#  define HAVE_STRTOUL
#  define HAVE_STRTOLL
#  define HAVE_STRTOULL
#  define HAVE_SYS_TIMEB_H
//#  define HAVE_FTIME
#  define HAVE_RAND_R
//#  define HAVE_GMTIME_R
#  define HAVE_LOCALTIME_R
#  define HAVE_STRERROR_R
#  define HAVE_TIMEGM
#  define HAVE_WCTOMB
#  define HAVE_MBTOWC
#  define HAVE_ISNAN
#  define HAVE_ISINF


 


makefile当中增加 -DHAVE_CONFIG_H


 


问题二:


如果要求压缩webservice返回结果,标准文档描述如下:


使用-DWITH_GZIP选项编译所有包含了stdsoap2.h或soapH.h的源程序,并将zlib库链接到您的代码,比如:在Unix/Linux平台下使用-lz.


传送gzip压缩的SOAP/XML数据,应设置输出模式为SOAP_ENC_ZLIB,例如:
 soap init(&soap);
 ...
 soap_set_omode(&soap, SOAP_ENC_ZLIB); // enable Zlib’s gzip
 if (soap_call_ns_myMethod(&soap, . . . ))
 ...
 soap_clr_omode(&soap, SOAP_ENC_ZLIB); // disable Zlib’s gzip
 ...


 


以上方案在-DHAVE_CONFIG_H情况下会失效,解决方案是在config.h文件中新增一行


#  define HAVE_ZLIB_H


 


总结:


以上两个问题标准文档中都没有提及,勉强通过源代码发现解决方案的。


感觉gsoap是个小众软件,有问题网上也搜索不到,希望对大家有帮助

原创粉丝点击