2

クロスプラットフォーム プログラムを SOAP Web サービスに接続する必要があります。gSOAP ツールの wsdl2h と soapcpp2 をコンパイルし、これらのツールを使用して .wsdl ファイルからソース コード ファイルを生成しました。stdsoap2.h に "#define WITH_OPENSSL" を定義し、この方法で SSL を使用しました。問題は、サービスを呼び出すと、SSL エラーを意味する ERROR 30 が返されることですが、実際に何が問題なのかわかりません。これはテスト環境であるため、サーバーが自己署名証明書を送信することはわかっています。実際、これに関連するエラーメッセージが出力されます。出力は次のとおりです。

Creating SOAP objects ...
Calling SOAP httpAccessService:
SSL verify error or warning with certificate at depth 0: self signed certificate
certificate issuer /C=IT/ST=Milan/L=Milan/O=Company/OU=Company/CN=company.it
certificate subject /C=IT/ST=Milan/L=Milan/O=Company/OU=Company/CN=company.it
SOAP ERROR 30

サービスを呼び出すために使用する関数は次のとおりです。

void gSOAPTesting::runTest() { int 結果 = 0; size_t requestSize; size_t 応答サイズ;

char endpoint[1024];
char buffer[8192];

string SoapAction;
struct soap *soap_container; 

ApplicationConfigurationServiceSoapBindingProxy Proxy1;

_ns1__httpAccessService *httpAccessService;
_ns1__httpAccessServiceResponse *httpAccessServiceResponse;

printf("Creating SOAP objects ...\n");
soap_container = soap_new();
//soap_container->mode   
httpAccessService = (_ns1__httpAccessService *) soap_instantiate(soap_container , SOAP_TYPE___ns1__httpAccessService , "" , "" , &requestSize);
httpAccessServiceResponse = (_ns1__httpAccessServiceResponse *) soap_instantiate(soap_container , SOAP_TYPE___ns1__httpAccessService , "" , "" , &responseSize);

soap_ssl_init(); /* init OpenSSL (just once) */

if(soap_ssl_client_context(soap_container ,
SOAP_SSL_DEFAULT ,
NULL,
NULL,
NULL,
NULL,
NULL     
) != SOAP_OK)
{
   printf("SOAP SSL Initialization Failure\n");  
   soap_print_fault(soap_container , stderr);
   return ;
}  

printf("Calling SOAP httpAccessService:\n");

SoapAction.clear();
SoapAction.append(SOAP_NAMESPACE_OF_ns1);
SoapAction.append("/");
SoapAction.append("httpAccessService");    

result = Proxy1.httpAccessService("https://XXX.XXX.XXX.XXX:XXXX" , NULL , httpAccessService , httpAccessServiceResponse);

if(result == SOAP_OK)
{
    printf("SOAP OK\n");                         
}
else
{
    printf("SOAP ERROR %d\n" , result);

    if(soap_check_state(soap_container) ) printf("Error: request soap struct not initialized\n");

    if(httpAccessService->soap == NULL)
    {
        printf("Error: NULL request SOAP struct\n");   
        return;                          
    }

    if(httpAccessService->soap->endpoint == NULL) printf("Error: Empty request endpoint\n");

    soap_stream_fault(soap_container , std::cout);        
}    

}

どんな助けでも大歓迎です。

4

2 に答える 2