• 0

[PHP] Trying to get a simple string to return from a WCF method...nightmare


Question

So I thought hey, I program C# and WCF all of the time. Lets try to have some fun with calling a WCF method with a PHP client. What a freaking nightmare this has been 2 hours later of searching google to find out WHY is it so hard to return a simple string (it wants to stick it in a stdClass object). I can get it to return the method call with the right data (just a get date/time function), however I can not for the life of me directly access the date time string returned. Here's my php code:


<?php
 $client = new SoapClient("http://localhost:8731/TestService?wsdl");
 $params = array('param1'=>'test user'); // these parameters don't mean anything php just forces you to give it parameters for some awful reason.
 $retval = $client->__soapCall("GetDateTime", $params);
 var_dump($retval);

 echo $retval->GetDateTimeResult->string;
 for($i=0;$i<count($retval->string);$i++)
 {
  echo $retval->string[$i]->GetDateTimeResult->string;
 }
?>

I've tried so many different variations. But this is always the result:

object(stdClass)#2 (1) { ["GetDateTimeResult"]=> string(32) "Date Time: 10/14/2012 5:10:13 PM" } // <--------- obviously the call is working b/c here is the right info.

Notice: Trying to get property of non-object in C:\xampp\htdocs\domains\testapp\test.php on line 7

Notice: Undefined property: stdClass::$string in C:\xampp\htdocs\domains\testapp\test.php on line 8

I just want to access the simple string. What do I have to do to do that?

3 answers to this question

Recommended Posts

  • 0

Ahhhh, I see the error. It was the next line causing the issue. I commented those lines out and I got what I needed. Thanks for offering that though I'm glad I retried it to see what I was doing wrong the first time.

This topic is now closed to further replies.
  • Posts

    • Ridiculous claim that the labor cost difference of $6000 annually would increase cost per phone by $200. The employees produce 3 phones per month or what?
    • Sparkle 2.20.1 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.1 changelog: You can now change the Animation Direction from Up, Left, or Off. Added configurable animation direction (Up, Left, Off) for improved accessibility Added TTL caching to the system info backend Refactored tweak application flow to await NvidiaProfileInspector Improved IPC listener cleanup to correctly remove specific listeners Fixed online status not updating after successful network requests Updated system info tests to support backend caching Removed electron-toolkit utils dependency in favor of internal is.dev helper Fixed unwanted files and folders being included in application bundles Download: Sparkle 2.20.1 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Never used the G7 Pro, but I've never had a good experience with that style of d-pad and fighting games.
    • And I just bought a seat cushion for my mesh chair. The chair feels nice but the first time I sat in it with boxers, I realized I don't like the feel of mesh on my legs. 😂
    • "This Dell 27 inch 4K 120Hz IPS monitor is really cheap after a very long time" ... Lol.
  • Recent Achievements

    • One Month Later
      JKR earned a badge
      One Month Later
    • Dedicated
      Asgardi earned a badge
      Dedicated
    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      +Edouard
      248
    3. 3
      PsYcHoKiLLa
      154
    4. 4
      Steven P.
      84
    5. 5
      macoman
      64
  • Tell a friend

    Love Neowin? Tell a friend!