gSOAP - Modify HTTP POST header

1.4k Views Asked by At

I am using the gSOAP generated classes to send and receive SOAP messages. The problem is that when I use the proxy like:

service.proxy_host = "some-proxy.mydomain.com";
service.proxy_port = 8080;

the POST header is being modified and is sending the entire endpoint URL and not just the application URL like this:

POST https://my-portal-server.mydomain.com/ecater/ws/rbiecat:data/some_Port HTTP/1.1

instead of just this:

POST /ecater/ws/rbiecat:data/some_Port HTTP/1.1

Can anyone tell me how I can modify the POST header before a request is sent? Or am I doing something wrong?

1

There are 1 best solutions below

1
On

When soap->proxy_host is set then the full URL is used in the POST header, because the proxy requires an absolute path to connect to the destination endpoint. This is a compliance requirement.

Alternatively, you can define a callback to override the HTTP post operation as follows:

soap_init1(&soap, ...); // etc
soap->fpost = myhttppost
...
int myhttppost(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count)
{
   // see stdsoap2.cpp http_post() for code to customize your HTTP POST operation
}