php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66768 SoapClient::__getLastRequest invalid output if SoapClient::__doRequest used
Submitted: 2014-02-25 12:10 UTC Modified: -
Votes:6
Avg. Score:3.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:2 (33.3%)
From: krzysztof dot lesiczka at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.5.9 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-02-25 12:10 UTC] krzysztof dot lesiczka at gmail dot com
Description:
------------
Method SoapClient::__getLastRequest shows message before use SoapClient::__doRequest , not truly sended message.
-

I was trying use SoapClient::__doRequest to change output xml
like here http://www.php.net/manual/en/soapclient.dorequest.php#74123

When i was trying check my request using:
echo $client->__getLastRequest();
it shows:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testnamespace.com/test/"><SOAP-ENV:Body><ns1:HelloWorld/></SOAP-ENV:Body></SOAP-ENV:Envelope>


But when i try to check network comunication
sudo tcpdump -A -i lo dst 127.0.0.1 and port 80
it shows:
...
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ><SOAP-ENV:Body><HelloWorld xmlns="http://testnamespace.com/test/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
...


Method SoapClient::__doRequest works fine 
but method SoapClient::__getLastRequest shows message before use SoapClient::__doRequest , not truly sended message.

Test script:
---------------
// client.php
<?php
class TestClient extends \SoapClient
{
    public function __doRequest($request, $location, $action, $version, $one_way = 0)
    {
        /*
         * http://www.php.net/manual/en/soapclient.dorequest.php#74123
         */
        $namespace = 'http://testnamespace.com/test/';
        $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="' . $namespace . '"', $request, 1);
        $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
        $request = str_replace(array('/ns1:', 'xmlns:ns1="' . $namespace . '"'), array('/', ''), $request);
        return parent::__doRequest($request, $location, $action, $version, $one_way);
    }
}

class HelloWorld {}

$options = array();
$client = new TestClient('soap-bug.wsdl', array('trace' => true));
$client->__soapCall('HelloWorld', array(new HelloWorld()));
echo $client->__getLastRequest();

// server.php
// http://www.php.net/manual/en/soapserver.construct.php#108987

Expected result:
----------------
echo $client->__getLastRequest();

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ><SOAP-ENV:Body><HelloWorld xmlns="http://testnamespace.com/test/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Actual result:
--------------
echo $client->__getLastRequest();

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testnamespace.com/test/"><SOAP-ENV:Body><ns1:HelloWorld/></SOAP-ENV:Body></SOAP-ENV:Envelope>

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 01:01:30 2024 UTC