これは、ヌルポインタの問題の逆参照です-ANSICドメインとgSoapドメインの両方で:
私は次のパブリックWSDLを使用しています:
http://www.mobilefish.com/services/web_service/countries.php?wsdl
そしてsoapUIを使用してその動作をテストしました。
wsdl2hおよびsoapcpp2ユーティリティを使用して、クライアント側のみのANSICバインディングを作成しました。
問題:
以前のgsoapプロジェクトでは、クライアントのsoap_call関数(5番目の引数)の結果構造には、次のようなもの以外の初期化は必要ありませんでした。
struct ns2__countryInfoByIanaResponse out, *pOut
pOut= &out;
このプロジェクトまで、これは常に十分でした。
クライアントsoap_callは次のようになります。
soap_call_ns2__countryInfoByIana(&soap, NULL, NULL, pIn, pOut); /* SOAP 1.2 RPC return element...*/
pIn
このプロジェクトでは、「us」や「nz」などchar *
の2文字のIANAコードが入力されたとして定義されます。pOut
この特定の呼び出しの戻り構造は、次のような形になっています。
struct ns2__countryInfoByIanaResponse
{
struct ns1__CountryData *countryinfo;
}
このns1__CountryData
ような形で:
struct ns1__CountryData
{
char *ianacode; /* required element of type xsd:string */
char *countryname; /* required element of type xsd:string */
float latitude; /* required element of type xsd:float */
float longitude; /* required element of type xsd:float */
};
したがって、アプリケーションからのこの関数の呼び出しは、次のように設定されます。
//declare response structure:
struct ns2__countryInfoByIanaResponse o, *pO;
void main(void)
{
pO = &o;
if(GetCountryInfo(buf, pO)==0)
{
pO->countryinfo->countryname; //Error Occurs Here...
}
}
エラーは、nullポインタpO->countryinfo
の間接参照として発生します
GetCountryInfoはここで定義されます:
int DLL_EXPORT GetCountryInfo(char *pIn, struct ns2__countryInfoByIanaResponse *pOut)
{
int status = 0;
size_t len=2048;
char buf[2048];
if (soap_call_ns2__countryInfoByIana(&soap, NULL, NULL, pIn, pOut)== SOAP_OK)
{
status = 0;
}
else
{
//soap_print_fault(&soap, stderr);
soap_sprint_fault(&soap, buf, len);
MessagePopup("soap error", buf);
status = 1;
}
return status;
}
同様の出力構造形状を使用する他のgSoap
プロジェクト(つまり、char *を含む構造を含む構造)は、上記で示したもの以外で初期化すると、完全に入力された結果を返しました。
何か案は?詳細をお知らせいただければお知らせください。ありがとう。