3

I have an application and want to add http header(not soap header) to it, but can not figure it out, anyone out there who can help.

Huang_Hai_Feng
  • 287
  • 2
  • 13
  • I can't research a complete answer now, but basically you need to get to the Transport object. There's an LWP::UserAgent in there somewhere. Get that, and add your header to it. There might be examples in the SOAP::Lite unit tests, look at the `t/` directory of the dist on cpan. – simbabque May 19 '20 at 14:27
  • 1
    You are right. I now can set http request head using soap service's transport object. – Huang_Hai_Feng May 20 '20 at 03:39

1 Answers1

3

I've got to set http request header using below code:

    my $transport = $service->transport;
    my $http_request = $transport->http_request;
    $http_request->header('x-api-key' => 'xaefdsfse' );
    $http_request->header('Content-Type' => 'application/soap+xml' );

Add this code before soap call.

Huang_Hai_Feng
  • 287
  • 2
  • 13