PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » SOAP » Bug #5004

Client: attachments array is not cleared properly

Details

Submitted2005-08-05 09:31 UTC
Fromlaihro at gmx dot de
Assignedyunosh
StatusClosed
PackageSOAP
PHP Version4.3.11
OSWindows XP SP2
Roadmaps(Not assigned)

Comments

[2005-08-05 09:31 UTC] laihro at gmx dot de

Description:
------------
In pear::soap 0.9.1 the SOAP_Base->__attachments Array is not properly cleared between two messages. The result is, that after receiving a message with attachments, parts of the attachment slip into the next message the client sends. This produces xml-errors like "content not allowed in prolog".

Test script:
---------------
[server]
<?php
$response = "------=_Part_13_18150163.1123064466959\nContent-Type: text/xml; charset=UTF-8\nContent-Transfer-Encoding: binary\nContent-Id: <E499622513F9AA87E77E75F8A2F73498>\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n<soapenv:Body>\n<ns1:getZippedCourseResponse soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"urn:WWRInterface\">\n<ns1:getZippedCourseReturn xsi:type=\"ns2:instance\" xmlns:ns2=\"WWREncoding\">\n<ns1:dataHandler href=\"cid:C8EFC5F183DA5492B74666A49D7603B4\" xmlns:ns3=\"http://xml.apache.org/xml-soap\"/>\n</ns1:getZippedCourseReturn>\n</ns1:getZippedCourseResponse>\n</soapenv:Body>\n</soapenv:Envelope>\n------=_Part_13_18150163.1123064466959\nContent-Type: text/xml\nContent-Transfer-Encoding: binary\nContent-Id: <C8EFC5F183DA5492B74666A49D7603B4>\n\nTEST\n------=_Part_13_18150163.1123064466959--\n";
header("Content-Type: multipart/related; type=\"text/xml\"; start=\"<E499622513F9AA87E77E75F8A2F73498>\"; boundary=\"----=_Part_13_18150163.1123064466959\"");
print $response;
?>

[client]
<?php
require_once 'SOAP/Client.php';
$client = new SOAP_Client("http://localhost/test/server.php");
$result = $client->call("attachTest", $param, array('trace' => 1));
$result = $client->call("attachTest", $param, array('trace' => 1));
print_r( $client->wire );
?>

Suggestion to patch this bug:
Change in Client.php SOAP_Client->call()

function &call($method, &$params, $namespace = false, $soapAction = false) {
$this->headersIn = null;
to
function &call($method, &$params, $namespace = false, $soapAction = false){
$this->__attachments = array();
$this->headersIn = null;

Expected result:
----------------
Client->wire:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

Actual result:
--------------
Client->wire:

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

[2006-01-11 10:19 UTC] laihro at gmx dot de

As I stated before the __attachments property slips into the next message a client sends, after the client received the message with the attachment. This behaviour can be easily repoduced with the test script. The error is produced by this call sequence:

client->call
server->response to client with an attachment
client->call -> produces error

The point is, that the error occurs when the client sends the next message. The new value for the __attachments property is not set until the client recieves a response to this message.
To fix this, you have to initialize __attachments before
$this->_soap_transport->send
is called or find out, how the property slips into the message.