4 Replies - 1225 Views - Last Post: 13 June 2011 - 09:09 AM Rate Topic: -----

#1 cdpace  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 48
  • Joined: 24-July 10

Getting data from WCF Server

Posted 12 June 2011 - 09:11 AM

Hello everyone,

I have set UP a WCF service running under basicHttpBinding. This WCF service has a method called Authenticate which returns a class of type UserInfo;

This is the code for the interface of the WCF Service

namespace SharezaBackEnd
{
    // NOTE: If you change the interface name "ISharezaBL" here, you must also update the reference to "ISharezaBL" in Web.config.
    [ServiceContract]
    public interface ISharezaBL
    {
        [OperationContract]
        UserInfo Authenticate(string Email, string Password);
        [OperationContract]
        string DoWork();
    }



    [DataContract]
    public class UserInfo
    {
       [DataMember]
       public string Token { get; set; }
       [DataMember]
       public string Error { get; set; }
    }
}



Now my problem is here.

I am trying to connect to this service from PHP. I have the following code that calls the WCF service in PHP

<?php
class BackEndHandler {


    function _construct() {
    }

    function Authenticate($param) {
        try {
            $wcfClient = new SoapClient("http://localhost:50850/SharezaBL.svc?wsdl");
            $returnValue = $wcfClient->Authenticate($param);
            return $returnValue;
        }catch (SoapFault $sf) {
            echo $sf->getMessage();
        }
    }

}
?>



and another page that calls this code

<div id="TopBar">
    <?php

    include 'API/BackEndHandler.php';

    $handler = new BackEndHandler();

    $param = Array
    (
      "Email" => "christianpace105@gmail.com",
      "Password" => "chris21448432"
    );

    $userinfo = $handler->Authenticate($param);
    echo $userinfo->Token;


    ?>
</div>



The problem lies in the part where there is echo $userinfo->Token its telling me "Undefined property: stdClass::$Token"

can anyone please help thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Getting data from WCF Server

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6037
  • View blog
  • Posts: 23,432
  • Joined: 23-August 08

Re: Getting data from WCF Server

Posted 12 June 2011 - 09:29 AM

You can get additional information about the transaction with the server via __getLastResponse(), but note also:

Quote

This method works only if the SoapClient object was created with the trace option set to TRUE.

Was This Post Helpful? 0
  • +
  • -

#3 cdpace  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 48
  • Joined: 24-July 10

Re: Getting data from WCF Server

Posted 12 June 2011 - 01:27 PM

So this will help me understand what the call is returning?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6037
  • View blog
  • Posts: 23,432
  • Joined: 23-August 08

Re: Getting data from WCF Server

Posted 12 June 2011 - 05:54 PM

Why not try it and find out???
Was This Post Helpful? 0
  • +
  • -

#5 cdpace  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 48
  • Joined: 24-July 10

Re: Getting data from WCF Server

Posted 13 June 2011 - 09:09 AM

Ok solved the problem guys basically the method Authenticate must come like this.

<?php
class BackEndHandler {


    function _construct() {
    }

    function Authenticate($param) {
        try {
            $wcfClient = new SoapClient("http://localhost:50850/SharezaBL.svc?wsdl");
            $returnValue = $wcfClient->Authenticate($param);
            return $returnValue->AuthenticateResult;
        }catch (SoapFault $sf) {
            echo $sf->getMessage();
        }
    }

}
?>






So basically
 $returnValue->AuthenticateResult 
this holds what the response is returning.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1