PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » SOAP » Bug #4980

Client: attachments in response not found

Details

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

Comments

[2005-08-03 10:13 UTC] laihro at gmx dot de

Description:
------------
PHP configuration: XAMPP Version 1.4.14
Pear::soap 0.9.1 seems to have a bug in the way attachments are handled. I am working on a soap client wich should receive an attachment from an axis service as a response to a certain function call. I know from the wire data, that this attachment has been send but the result of SoapClient->call() is empty. After some research I found out, that this is caused by Base.php. It cuts the "content-id" (cid) by one character, thereby preventing the cid to be found in the attachments-array by Parser.php.
A workaround wich worked for me is given below, but I don't know whether this gives rise to other problems.

Test script:
---------------
SOAP-RESPONSE wich produces this behavior:

<?xml version="1.0" encoding="UTF-8"?>
<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">
<soapenv:Body>
<ns1:getZippedCourseResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:WWRInterface">
<ns1:getZippedCourseReturn xsi:type="ns2:instance" xmlns:ns2="WWREncoding">
<ns1:dataHandler href="cid:17E845570891EA5C9C39EE6A5615AEC4" xmlns:ns3="http://xml.apache.org/xml-soap"/>
</ns1:getZippedCourseReturn>
</ns1:getZippedCourseResponse>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_11_996231.1123060972278
Content-Type: application/zip
Content-Transfer-Encoding: binary
Content-Id: <17E845570891EA5C9C39EE6A5615AEC4> ..CDATA..

Suggestion to patch this bug:
Replace Base.php SOAP_Base_Object->_decodeMimeMessage

} else {
$cid = 'cid:' . substr($p->headers['content-id'], 1, -2);
$attachments[$cid] = $p->body;
}

with

} else {
$cid = 'cid:' . substr($p->headers['content-id'], 1, -1);
$attachments[$cid] = $p->body;
}

Expected result:
----------------
Base.php SOAP_Base_Object->__attachments :

Array ( [cid:17E845570891EA5C9C39EE6A5615AEC4] => ..CDATA..)

Actual result:
--------------
Base.php SOAP_Base_Object->__attachments :

Array ( [cid:17E845570891EA5C9C39EE6A5615AEC] => ..CDATA..)

Notice the missing character '4' at the end of the array key.

[2005-08-03 12:21 UTC] laihro at gmx dot de

Script to reproduce the behavior:

[server.php]
<?php
header("Content-Type: multipart/related; type=\"text/xml\"; start=\"<E499622513F9AA87E77E75F8A2F73498>\"; boundary=\"----=_Part_13_18150163.1123064466959\"");
$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";
print $response;
?>

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

Result is:
stdClass Object ( [dataHandler] => )
and should be:
stdClass Object ( [dataHandler] => TEST)

[2005-12-08 21:47 UTC] rbro at hotmail dot com

I just wanted to check if there was any update on this bug, as I'm running into the exact same issue and the suggested fix seems to fix it.