Header sample.gif

Printing Response from a SOAP API call

It is helpful to print out the response from a SOAP API call. All calls return a response.

Here is a sample query call:

  ...
  // Print raw response
  $response = $mySforceConnection->query($query);
  print_r($response);

  // Print formatted queryResult
  $queryResult = new QueryResult($response);
  print_r($queryResult);
  ...

Here is the expected output:

stdClass Object
(
    [done] => 1
    [queryLocator] =>
    [records] => Array
        (
            [0] => stdClass Object
                (
                    [type] => Account
                    [Id] => Array
                        (
                            [0] => 0015000000F7Ib3AAF
                            [1] => 0015000000F7Ib3AAF
                        )

                    [any] => <sf:Name>TestCompany</sf:Name><sf:BillingStreet xs
:nil="true"/><sf:BillingCity xsi:nil="true"/><sf:BillingState xsi:nil="true"/><
f:Phone xsi:nil="true"/><sf:Fax xsi:nil="true"/>
                )

            [1] => stdClass Object
                (
                    [type] => Account
                    [Id] => Array
                        (
                            [0] => 0015000000L3zYdAAJ
                            [1] => 0015000000L3zYdAAJ
                        )

                    [any] => <sf:Name>Golden Straw</sf:Name><sf:BillingStreet>4
22 Haystack Boulevard</sf:BillingStreet><sf:BillingCity>Wichita</sf:BillingCity
<sf:BillingState>KA</sf:BillingState><sf:Phone>666.666.6666</sf:Phone><sf:Fax>5
5.555.5555</sf:Fax>
                )

        )

    [size] => 2
)
QueryResult Object
(
    [queryLocator] =>
    [done] => 1
    [records] => Array
        (
            [0] => SObject Object
                (
                    [type] => Account
                    [fields] => SimpleXMLElement Object
                        (
                            [Name] => TestCompany
                            [BillingStreet] => SimpleXMLElement Object
                                (
                                )

                            [BillingCity] => SimpleXMLElement Object
                                (
                                )

                            [BillingState] => SimpleXMLElement Object
                                (
                                )

                            [Phone] => SimpleXMLElement Object
                                (
                                )

                            [Fax] => SimpleXMLElement Object
                                (
                                )

                        )

                    [Id] => 0015000000F7Ib3AAF
                )

            [1] => SObject Object
                (
                    [type] => Account
                    [fields] => SimpleXMLElement Object
                        (
                            [Name] => Golden Straw
                            [BillingStreet] => 4322 Haystack Boulevard
                            [BillingCity] => Wichita
                            [BillingState] => KA
                            [Phone] => 666.666.6666
                            [Fax] => 555.555.5555
                        )

                    [Id] => 0015000000L3zYdAAJ
                )

        )

    [size] => 2
)