0

I am trying to add custom HTTP headers in a SOAP request using C++Builder XE2. As I didn't see any c++ template, I used as sample the following Delphi code and this other one, but without any success. The event handler is even not triggered.

Any idea to fixe the issue will be really appreciated.

Below is my code.

//.h
private:    // Déclarations utilisateur
    void __fastcall HTTPRIOBeforePost(const THTTPReqResp* HTTPReqResp, void * Data);
//---------------------------------------------------------------------------
//.cpp
void __fastcall TForm1::FormShow(TObject *Sender)
{//
 _di_MyServicesPort MSPort = NS_MyServices::GetMyServicesPort(true, "https://www.example.com/MyServices.wsdl");

 // /Set headers
 THTTPRIO *HTTPRIO = new THTTPRIO(NULL);
 HTTPRIO->URL = L"https://www.example.com/MyServices.wsdl";
 HTTPRIO->HTTPWebNode->OnBeforePost = &HTTPRIOBeforePost;
 // \Set header

 UnicodeString US_MSPort = MSPort->TESTDisplay(-1);
//...
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HTTPRIOBeforePost(const THTTPReqResp* HTTPReqResp, void * Data)
{//
 HttpAddRequestHeaders(Data, TEXT("UserID: My_UserID\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
 HttpAddRequestHeaders(Data, TEXT("Password: My_Password\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
 HttpAddRequestHeaders(Data, TEXT("Content-Type: My_Content-Type\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
 HttpAddRequestHeaders(Data, TEXT("User-Agent: My_User-Agent\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
 HttpAddRequestHeaders(Data, TEXT("Authorization: My_Authorization\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
}
//---------------------------------------------------------------------------
``
ibouka
  • 13
  • 1
  • 5

0 Answers0