2012-02-29 14 views
1

gSoapを使用してWebサービスを作成しています。ヘッダファイルには、戻り値の型がenum値であるメソッド定義がほとんどありません。私は「戻り値として列挙型を持つ複数のメソッドを持っている場合は、さらにsoapcpp2の戻り値としての列挙型

sample.h(20): syntax error 
sample.h(21): Syntax error: input before ; skipped 

:私はsoapcpp2.exeツールを実行すると、私はこのエラーを取得していたヘッダファイルを渡している それはsoapcpp.exeと制限

// enum definition 
enum status {ok, error}; 

// method definition 
status ns_calc(int a, int b); 

です:

**WARNING**: Duplicate declaration of 'sample_status_____' (already declared at li ne 31), changing conflicting identifier name to new name sample_status______'. Note: this problem may be caused by importing invalid XML schemas (detected at line 38 in sample.h)

私のヘッダファイルは次のようなになりますmがこの警告を取得しますか?

答えて

3

書き込み中のヘッダーファイルはいくつかのgSoap規則に従わなければなりません。したがって、関数の出力は最後の引数でなければなりません。 documentationから:この例では、明示的にXML-スキーマ(xsd__)タイプ、this practice is advised to improve interoperabilityを使用していることを

enum ns__status { ok, error }; 
int ns__calc(xsd__int a, xsd__int b, enum ns__status& out); 

注:

By convention, all parameters are input parameters except the last. The last parameter is always the output parameter. A struct or class is used to wrap multiple output parameters, see also Section 7.1.9. This last parameter must be a pointer or reference. By contrast, the input parameters support pass by value or by pointer, but not pass by C++ reference.

ヘッダファイル内の関連する部分は次のようになります。 cppファイルの関連部分は次のようになります:

int ns__calc(struct soap* soap, xsd__int a, xsd__int b, enum ns__status& out) 
{ 
    // do something with 'a' and 'b' and set 'out' 
    out = ... 
    return SOAP_OK; 
}