php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49070 return object array in a webservice
Submitted: 2009-07-27 09:34 UTC Modified: 2009-10-16 01:00 UTC
Votes:29
Avg. Score:4.7 ± 0.6
Reproduced:27 of 27 (100.0%)
Same Version:11 (40.7%)
Same OS:7 (25.9%)
From: jordibsala at gmail dot com Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.3.0 OS: windows xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jordibsala at gmail dot com
New email:
PHP Version: OS:

 

 [2009-07-27 09:34 UTC] jordibsala at gmail dot com
Description:
------------
I have a problem when I call a function of a JAVA webservice which 
returns a array of objects, but this array's objects are empty.


Reproduce code:
---------------
        $wsdl =          "http://localhost:8180/ContentManager/services/ContentManagerWS?wsdl";
	
	$contentId = "hola";
	$metadataSet = 2;

	$client = new SoapClient($wsdl);
	$params =  array('contentId' => $contentId,'metadataSet' => $metadataSet);
	try
	{	
 	   $result = $client->__soapCall('getMetadata', array('parameters' => $params));
    } catch (SoapFault $exception) {
        echo $exception;
	}

?>
<?php var_dump($result)?>

Expected result:
----------------
object(stdClass)#2 (1) { ["getMetadataReturn"]=> object(stdClass)#3 (6) 
{ ["contentID"]=> string(36) "6b9f1157-78c2-4e2d-b371-888839431088" 
["raudolares"]=> int(100) ["thumbnail"]=> string(45) 
"http://www.thumbnailsraudos.es/thumbnail1.jpg" 
["RecommendationValue"]=> int(12) ["semanticData"]=> object(stdClass)#4 
(5) { ["emitDate"]=> string(10) "21/07/2009" ["filmDate"]=> string(10) 
"21/05/2009" ["editDate"]=> string(10) "21/06/2009" ["edited"]=> 
bool(true) ["labeled"]=> bool(false)  } ["technicalData"]=> array(5) { 
[0]=> object(stdClass)#9 (2) {["bitrate"]=> int(1024000) ["filesize"]=> 
int(51236254) } [1]=> object(stdClass)#10 (2) { ["bitrate"]=>int(512000) 
["filesize"]=> int(21365245) } [2]=> NULL [3]=> NULL [4]=> NULL } } }

Actual result:
--------------
object(stdClass)#2 (1) { ["getMetadataReturn"]=> object(stdClass)#3 (6) 
{ ["contentID"]=> string(36) "6b9f1157-78c2-4e2d-b371-888839431088" 
["raudolares"]=> int(100) ["thumbnail"]=> string(45) 
"http://www.thumbnailsraudos.es/thumbnail1.jpg" 
["RecommendationValue"]=> int(12) ["semanticData"]=> object(stdClass)#4 
(5) { ["emitDate"]=> string(10) "21/07/2009" ["filmDate"]=> string(10) 
"21/05/2009" ["editDate"]=> string(10) "21/06/2009" ["edited"]=> 
bool(true) ["labeled"]=> bool(false)  } ["technicalData"]=> array(5) { 
[0]=> object(stdClass)#9 (0) { } [1]=> object(stdClass)#10 (0) { } [2]=> 
NULL [3]=> NULL [4]=> NULL } } }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-08 20:00 UTC] Sjoerd@php.net
Thank you for your bug report.

To properly diagnose and reproduce the problem, we need the SOAP response from the server when it returns the array. You can obtain this by calling __getLastRequest() or using a sniffer like Wireshark.
 [2009-10-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-06-08 15:01 UTC] moshe dot elisha at gmail dot com
I have the same problem with a SOAP request to a Java Axis WS.

(I replaced all http:// with hdoubletp://)

My Request is ($soapClient->__getLastRequest()):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="hdoubletp://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="hdoubletp://pm.xms.xeround.com"><SOAP-ENV:Body><ns1:getInstanceGraphsInitialData><ns1:in0>34</ns1:in0><ns1:in1>0</ns1:in1><ns1:in2>10800</ns1:in2><ns1:in3>3600</ns1:in3></ns1:getInstanceGraphsInitialData></SOAP-ENV:Body></SOAP-ENV:Envelope>

My response is ($soapClient->__getLastResponse()):

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="hdoubletp://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="hdoubletp://www.w3.org/2001/XMLSchema" xmlns:xsi="hdoubletp://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getInstanceGraphsInitialDataResponse xmlns="http://pm.xms.xeround.com"><getInstanceGraphsInitialDataReturn><time>1275998951000</time><values><values>0</values><values>0</values><values>13</values><values>6</values></values></getInstanceGraphsInitialDataReturn><getInstanceGraphsInitialDataReturn><time>1275995351000</time><values><values>0</values><values>0</values><values>11</values><values>5</values></values></getInstanceGraphsInitialDataReturn></getInstanceGraphsInitialDataResponse></soapenv:Body></soapenv:Envelope>

print_r of the result ($soapClient->__soapCall(...)->getInstanceGraphsInitialDataReturn):

Array
(
    [0] => stdClass Object
        (
            [time] => 1275998951000
            [values] => stdClass Object
                (
                )

        )

    [1] => stdClass Object
        (
            [time] => 1275995351000
            [values] => stdClass Object
                (
                )

        )

)
 [2011-03-23 19:37 UTC] lherrington100 at gmail dot com
I found this bug from a stack overflow and posted my solution there:

http://stackoverflow.com/questions/1830801/php-soapclient-call-response-missing-parts-of-answer/5409920#5409920

It may or may not be what you need, but in my experience this is not a PHP bug. It is an issue with how your web service is written.
 [2011-03-23 19:44 UTC] lherrington100 at gmail dot com
Here is a copy/paste of my answer from stack overflow, just in case that goes away someday:

"Here we go nearly a year and a half later...

In my recent semi-similar experience this was not a php bug. It is an issue related to the way your webservice is written and how PHP reads the output. I was experiencing a similar problem (even down to getLastResponse returning the correct XML) and came to find that it wasn't so much PHP or my SOAP function that had an issue but that the result of the "broken" function was not an explicitly defined cursor.


Example of bad cursor definition:

    PROCEDURE GetBlahByBlahID(IN IN_BLAH_ID VARCHAR, IN IN_BLAHPKG VARCHAR,                                     
    OUT result CURSOR
    ) BEGIN ...



Example of good cursor definition: 

    PROCEDURE GetBlahByBlahID(IN IN_BLAH_ID VARCHAR, IN IN_BLAHPKG VARCHAR,                                     
    OUT result CURSOR (  BLAH VARCHAR(250),
                         BLAH2 VARCHAR(250),
                         BLAH_DATE DATE,
                         BLAH3 VARCHAR(250))) BEGIN ...

Apparently Java can handle the "bad"/non explicit output just fine, but PHP returns an array of null objects.

Not sure if this will help you, but defining the web service function output as the "good" way above fixed my problem."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC