步驟這樣:
寫一個頭檔案server.h:
int ns__add(int num1, int num2, int *sum);
用soapcpp2.exe生成相關的檔案,其中包含一個ns.wsdl
再用wsdl2h -s -o service.h D:\XXX\ns.wsdl(我也不知道這樣對不對 依葫蘆畫瓢)
結果生成出來的service.h變成了這樣
int __ns1__add(
_ns2__add* ns2__add, ///< Input parameter
_ns2__addResponse &ns2__addResponse ///< Output parameter
);
class _ns2__add
{ public:
/// Element "num1" of XSD type xs:int.
int num1 1; ///< Required element.
/// Element "num2" of XSD type xs:int.
int num2 1; ///< Required element.
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
struct soap *soap ;
};
class _ns2__addResponse
{ public:
/// Element "sum" of XSD type xs:int.
int* sum 0; ///< Optional element.
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
struct soap *soap ;
};
為何明明很簡單的一個函式,卻被包裝成這樣?如果我用這樣的頭檔案soapcpp2.exe 生成出來的檔案肯定和之前用server.h的不一樣,最后多半呼叫不成功吧
是不是我生成頭檔案的方式有誤?
uj5u.com熱心網友回復:
我也這問題,估計是生存的wsdl檔案不能用。不知樓主解決沒uj5u.com熱心網友回復:
生成規則就是這樣,你沒必要糾結這些。你要用別人的東西,就要遵循別人的協議。uj5u.com熱心網友回復:
因為需要序列化等,所以會生成一些結構資料來進行處理uj5u.com熱心網友回復:
我改了一下.h檔案的編碼格式,//gsoap ns service encoding: encoded 改為Literal 。就出現這個情況了,客戶端寫好,呼叫,提示SOAP-ENV:Server[no subcode],看論壇說是埠不對應,不知道是啥問題
uj5u.com熱心網友回復:
你只有.h檔案,沒有實作的cpp檔案?實作的cpp函式還要在引數串列里加一個soap* t_soap引數,這個引數傳入的是連接引數,包括埠。可以參考這個http://blog.csdn.net/educast/article/details/12653069
uj5u.com熱心網友回復:
其實這個不影響Java客戶端的呼叫,沒有別的影響。比較糾結的是為什么編碼方式不一樣,用wsdl2h生成的.h檔案不一樣呢?其實,我感覺也不用wsdl2生成.h檔案,直接用自己定義的.h 就行,直接生成c++客戶端代碼,完成c++客戶端。
還有一點就是發布的時候,.h檔案中的localhoust要改成局域網IP
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/106587.html
標籤:基礎類
上一篇:大神求救a~VS2012安裝了無數遍,還是不能運行程式啊~~~T.T
下一篇:這個界面怎么畫
