ID:               44482
 Comment by:       bugs dot php dot net at ceesco dot com
 Reported By:      j dot dunn5 at ntlworld dot com
 Status:           Open
 Bug Type:         SOAP related
 Operating System: RedHat
 PHP Version:      5.2.5
 New Comment:

I have been facing the same issue, more specificly, PHP SOAP client in
the WSDL mode can not handle complex types (nested elements). No matter
if the data passed to client is created with SoapParam(), SoapVar(), a
class, or arrays; the nested elements are either missing or have
irrelevant structure and attributes. PHP SOAP
$client->__getLastRequest() can be used to view the structure of the XML
sent to the .NET server in WSDL mode. Here is a sample to be tested and
reproduced:

I want the output of the XML client look like:
_________________________________________________________________
<SubmitInquiry xmlns="http://some.NETwebservices.c/";>
        <basketItems>
                <anyType xsi:type="BasketItem">
                        <m_itemID>6729</m_itemID>
                        <m_retailPrice>1.35</m_retailPrice>
                        <m_indexNum>2</m_indexNum>
                </anyType>
                <anyType xsi:type="BasketItem">
                        <m_itemID>3434</m_itemID>
                        <m_retailPrice>1.39</m_retailPrice>
                        <m_indexNum>1</m_indexNum>
                </anyType>
                <anyType></anyType>
        </basketItems>
        <affiliateName>myName</affiliateName>
        <password>myPass</password>
</SubmitInquiry>
_________________________________________________________________

Here are different ways I have tried to create the anyType elements
within the basketItems:
_________________________________________________________________
$SubmitInquiryParameters['affiliateName'] = 'myName';
$SubmitInquiryParameters['password'] = 'myPass';
$temp_array = array(
     'm_itemID' => '6729',
     'm_retailPrice'  => 1.39,
     'm_indexNum' => 1);
$SubmitInquiryParameters['basketItems']['anyType'][] = new
SoapVar($temp_array,0,'BasketItem','tns','anyType',''); 
_________________________________________________________________

Here I have hard coded the XML for the complex nodes but the client
still drops the node entirely:

$SubmitInquiryParameters['affiliateName'] = 'myName';
$SubmitInquiryParameters['password'] = 'myPass';
$SubmitInquiryParameters['basketItems'] = '<anyType
xsi:type="BasketItem"><m_itemID>6729</m_itemID><m_retailPrice>1.35</m_retailPrice><m_indexNum>2</m_indexNum></anyType>';
_________________________________________________________________


In every case the anyType is an empty node in the request sent by the
PHP SOAP client: 

<ns2:basketItems><ns2:anyType
xsi:type="ns1:BasketItem"/></ns2:basketItems>

So I believe, the SOAP client in WSDL mode can't process complex types
and drops the data.


Previous Comments:
------------------------------------------------------------------------

[2008-03-19 16:37:40] j dot dunn5 at ntlworld dot com

Description:
------------
Hello,

There seems to be many unsolved occurances of the following bug when
trying to establish a SOAP connection to a .NET endpoint:

Server was unable to process request. ---> Object reference not set to
an instance of an object.

I am yet to find a solution - the same application works fine when
connected to from a .net platform.

Reproduce code:
---------------
<?php

ini_set('display_errors', 1);
ini_set("soap.wsdl_cache_enabled", 0);

$params = new stdClass;
$params->POS->Source = (object)array('ISOCountry' => 'GB',
'ISOCurrency' => 'GBP');
$params->POS->Source->BookingChannel->CompanyName =
(object)array('CompanyShortName' => 'Testing');
$params->AvailRequestSegments->UTSv_AvailRequestSegment->StayDateRange->StartDateWindow
= (object)array('EarliestDate' => '2008-04-01');
$params->AvailRequestSegments->UTSv_AvailRequestSegment->StayDateRange->EndDateWindow
= (object)array('EarliestDate' => '2008-04-02');
$params->AvailRequestSegments->UTSv_AvailRequestSegment->ConsumerCandidates->ConsumerCandidate->ConsumerCounts->ConsumerCount
= (object)array('AgeQualifyingCode' => 'Adult', 'Count' => 2);
$params->AvailRequestSegments->UTSv_AvailRequestSegment->TPA_Extensions->SearchCriteria
= (object)array('IndustryClassification' => 1);

try {

        $client = new SoapClient(
                "http://www.testing123.com/AvailabilityService.asmx?WSDL";,
                array('trace' => true)
        );

        $client->SearchSupplierProductTypeAvailability($params);

    echo $client->__getLastRequestHeaders() . "\r" .
$client->__getLastRequest() . "\r\r" . $client->__getLastResponse();;
        
}
catch (Exception $e) {

    echo "Error!<br />";
    echo $e -> getMessage ();
        
}

?>



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44482&edit=1

Reply via email to