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 #2877

BUG: Response named as "Return"

Details

Submitted2004-12-03 09:50 UTC
Frompear dot php dot net at inxon dot de
Assignedyunosh
StatusDuplicate
PackageSOAP
PHP Version4.3.4
Roadmaps(Not assigned)

Comments

[2004-12-03 09:50 UTC] pear dot php dot net at inxon dot de

Description:
------------
[See PEAR::SOAP <return> tag trouble in migration to PEAR::SOAP from NuSOAP in newsgroup pear.soap]
Sometimes SOAP::PEAR responds with an additional <Return>-Tag around the response. This return-Tag is not part of the wsdl and many SOAP-Clients fail, so this is a serious bug.

SOLUTION:
Edit Server.php
[Lines 270 ...]
Original:
...
if (is_array($return_type) && is_array($method_response)) { $i = 0; foreach ($return_type as $key => $type) {
...

BUGFIX:
...
/* 2004-12-03 (rs) */
if (is_array($return_type) || /* !!! */ is_array($method_response)) { $i = 0;
if (is_array($return_type))
$_rt=$return_type;
else
$_rt=$method_response;
foreach ($_rt /* !!! */ as $key => $type) {
...

Hope this helps,
Rgs - Ro!and.

Reproduce code:
---------------
...
return array('lastStatus' => 'ok');

Expected result:
----------------
<lastStatus
xsi:type="xsd:string">ok</lastStatus>

Actual result:
--------------
<return xsi:type="xsd:string">
<lastStatus
xsi:type="xsd:string">ok</lastStatus></return></ns4:reportInResponse>

[2005-02-22 10:39 UTC] smith at backendmedia dot com

thx .. hopefully someone will soon take care of the buzg report. could you use unified diffs in the future to provide more context about your patch?

[2006-08-11 09:49 UTC] JW00000 at gmail dot com

This same bug happened to me, and the fix provided solved the problem. The problem happened to me when creating a SOAP Server that automatically "translated" a WSDL file into PHP. I had the following function, mapped to the server:

function GetNote($id) {
return array(
new SOAP_Value('id', 'int', $id),
new SOAP_Value('title', 'string', 'Title'),
new SOAP_Value('tags', 'string', 'ta, gs'),
new SOAP_Value('content', 'string', 'note')
);
}

Hereupon, the server reponded the following:

...
<SOAP-ENV:Body>
<ns4:GetNoteResponse>
<return>
<id>1</id>
<title>Title</title>
<tags>ta, gs</tags>
<content>note</content>
</return>
</ns4:GetNoteResponse>
</SOAP-ENV:Body>
...

But, according to my WSDL, there shouldn't be any <return>s. I edited the Server.php with the fix provided above, and the bug was solved.

I hope this fix can be added to a new version of PEAR::SOAP soon, as it seems like this bug report got submitted quite a time ago, and it still didn't got patched. It also doesn't seem a duplicate of bug 2694, since that error got fixed and this one still happens to me.