SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is the best way to read values from stdclass object

    I am accessing a Java web service in PHP and it is returning a STDCLASS Array.

    The below is the array - i want to know the easiest way of accessing the values in this array.

    __________

    stdClass Object
    (
    [return] => stdClass Object
    (
    [agentCode] =>
    [message] =>
    [agentName] =>
    [consignment] =>
    [importersName] =>
    [serviceDetailList] => stdClass Object
    (
    [item] => Array
    (
    [0] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1001
    [tariffCode] => 705
    [serviceName] => WASHING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10001
    )

    [1] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1002
    [tariffCode] => 705
    [serviceName] => PAINTING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10002
    )

    [2] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1003
    [tariffCode] => 705
    [serviceName] => REPAIRING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10003
    )

    [3] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1004
    [tariffCode] => 705
    [serviceName] => CLEANING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10004
    )

    [4] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1005
    [tariffCode] => 705
    [serviceName] => MOVING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10005
    )

    [5] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1001
    [tariffCode] => 705
    [serviceName] => WASHING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10001
    )

    [6] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1002
    [tariffCode] => 705
    [serviceName] => PAINTING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10002
    )

    [7] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1003
    [tariffCode] => 705
    [serviceName] => REPAIRING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10003
    )

    [8] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1004
    [tariffCode] => 705
    [serviceName] => CLEANING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10004
    )

    [9] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1005
    [tariffCode] => 705
    [serviceName] => MOVING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10005
    )

    [10] => stdClass Object
    (
    [amount] => 50
    [serviceID] => 1001
    [tariffCode] => 705
    [serviceName] => WASHING
    [chargeCode] => IMPCLCDPCI
    [containerSize] => 20
    [portCode] => J
    [serviceRefId] => 10001
    )

    )

    [consignmentCode] =>
    [agentType] =>
    [consignmentType] =>
    [chargeCode] =>
    [line] =>
    [moveType] =>
    [containerSize] => 20
    [containerNumber] => RSI180913
    [serviceID] =>
    [desig] =>
    [chargeCollectionID] =>
    [requestNumber] =>
    [customerCode] =>
    [amount] => 0
    [tariffCode] =>
    [customerType] =>
    [serviceName] =>
    [customerName] =>
    [createDate] => 2013-09-18 12:18:00.0
    [portCode] =>
    [serviceRefId] =>
    )

    )

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Assume $response holds the object that gets returned, you can use something like the below.

    PHP Code:
    $response->return->serviceDetailList->containerNumber 

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - this is working and most of the work is done now but i am caught at one place. The below is an explanation of a function that i have to call and pass data to it to do some processing in the system.

    ________________________________________________________________________________

    InputParameterName Type

    containerNumber String
    serviceIDs List
    totalAmount Double
    prepaidKey String
    cardPin String


    For output we have used PaymentTransactionDTO object, have properties –

    Properties Name Type

    containerNo String
    receiptNO String
    msrNumber String
    serviceDate Date
    customerName String
    prepaidKey String
    companyName String
    poBox String
    phoneNoJA String
    faxNoJA String
    phoneNoPR String
    faxNoPR String
    Email String


    ________________________________________________________________________________

    I am using the below cost but it is giving me an error :

    $soap_client = new SoapClient("http://11.11.111.11:9999/xxxx/xxxxxx?WSDL");
    $ServicesList = array(1001,1005);
    $Array=$soap_client->paymentTransactionDetails($ContainerNumber,$ServicesList,$TotalAmount,$PrepaidKey,$Pin);

    The below is the error i am getting :

    “Caught exception while handling request: expected element is missing: prepaidKey”

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,191
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Have you tried dumping the variable values to see if they're valid?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •