時間又快晚上12點了。
整理一下今天的進度。
從wsdl 裏產生 h標頭檔。
wsdl檔,原來都是一些可以下載的檔案。
下載來看看也行。
gsoap2的 wsdl2h 支援檔案,和超連結的方式。
昨天做過了,複習一下。
wsdl2h -o calc.h http://www.genivia.com/calc.wsdl
產生了 calc.h
To complete the process, compile with:
soapcpp2 calc.h
or to generate C++ proxy/object classes:
soapcpp2 -i calc.h
然後,
soapcpp2 -i calc.h
產生錯誤,
Critical error: #import: Cannot open file "stlvector.h" for reading.
Hint: use option -I<path> (you can define multiple paths separated with ':')
接著。
按照提示,
用指令,
find -file "stlvector.h"
找到位置
soapcpp2 -I/usr/local/share/gsoap/import calc.h
產生一堆檔案。
編了一個測試程式,
$ cat main.cpp
#include "soapcalcProxy.h" // get proxy
#include "calc.nsmap" // import the generated namespace mapping table
int main()
{
calcProxy calc(SOAP_XML_INDENT);
double sum;
if (calc.add(1.0, 2.0, sum) == SOAP_OK)
std::cout << "Sum = " << sum << std::endl;
else
calc.soap_stream_fault(std::cerr);
return calc.error; // nonzero when error
}
$ g++ -o myclient main.cpp stdsoap2.cpp soapC.cpp soapClient.cpp
g++: stdsoap2.cpp: No such file or directory
main.cpp: In function ‘int main()’:
main.cpp:5: error: ‘calcProxy’ was not declared in this scOK
編譯不過,找到stdsoap2.cpp,可解第一個問題。
但第二個問題, ‘calcProxy’
C++不是筆者常用的語言。
$ grep -r "calcProxy" *
calc.h:C++ proxy class (defined in soapcalcProxy.h):
calc.h: class calcProxy;
calc.h:C++ proxy class (defined in soapcalcProxy.h):
calc.h: class calcProxy;
calc.h:C++ proxy class (defined in soapcalcProxy.h):
calc.h: class calcProxy;
calc.h:C++ proxy class (defined in soapcalcProxy.h):
calc.h: class calcProxy;
calc.h:C++ proxy class (defined in soapcalcProxy.h):
calc.h: class calcProxy;
main2.c:#include "soapcalcProxy.h" // get proxy
main2.c: calcProxy calc(SOAP_IO_KEEPALIVE); // keep-alive improves connection performance
main.cpp:#include "soapcalcProxy.h" // get proxy
main.cpp: calcProxy calc(SOAP_XML_INDENT);
soapcalcProxy.h:/* soapcalcProxy.h
soapcalcProxy.h:#ifndef soapcalcProxy_H
soapcalcProxy.h:#define soapcalcProxy_H
再想想這個物件怎麼沒有在scope裏呢??