2015-04-06 40 views
0

charint,返回值傳遞良好。gsoap linux C++ /結構失敗傳遞

struct傳遞失敗。

服務器:

soapcpp2 -2 -SLix ... 

客戶端:

wsdl2h -f -s -o ... ... 
soapcpp2 -i -C ... 

struct{ 
    char * value; 
}USER_ITEM 

服務器:

int Service::GetValue(struct USER_ITEM * item) 
{ 
    item->value = new char[100]; 
    item->value = "example"; 
} 

客戶:

.... 
ns2__useritemresponse user; 
proxy.Getvalue(user) 
user.user_item->value // user.user_item address is null; 
.... 

窗戶很好。但不是在Linux C++上。

與上述格式相同。

我需要一組單獨的選項嗎?

如果您懷疑部件,請幫助。

對不起,我的英語說得不好。

感謝您的閱讀。

+0

如果用-Wall和-Werror編譯你得到任何警告?方法是「GetValue」還是「Getvalue」,它的聲明在代理基類中是什麼樣的。 – 2015-04-06 10:39:36

回答

1

您不能使用賦值運算符複製一個字符指針,這不是一個的std :: string:

item->value = new char[100]; 
strcpy(item->value, "example"); 
+0

謝謝你的答案。 但這不是問題。 server: 'cout << item-> value << endl; //輸出沒問題。' 但是 服務器: 'user.user_item // null'和 'user.user_item-> value // not found' – AKUMA 2015-04-06 05:07:27

+1

你的代碼看起來很腥。它不應該讀'proxy.Getvalue(user.user_item);'?請發佈您的*真實*代碼。編譯的那個。 – nvoigt 2015-04-06 05:14:49