0

I created web service using asp.net framework 4 :

[WebMethod]
public DataSet GetMembers(string memberId, string thirdName)
{
    string connStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
    SqlConnection cn = new SqlConnection(connStr);
    SqlDataAdapter da = new SqlDataAdapter();
    DataSet ds = new DataSet();

    da.SelectCommand = new SqlCommand(@"SELECT MemberMaster.MemberId,MemberMaster.FirstName,MemberMaster.SecondName,MemberMaster.ThirdName,MemberMaster.CivilNo,MemberMaster.DateOfBirth,MemberSubcription.MemberId
                                        FROM MemberMaster inner join MemberSubcription on MemberMaster.MemberId=MemberSubcription.MemberId
                                        WHERE MemberMaster.MemberId=@MemberId and MemberMaster.ThirdName=@ThirdName", cn);
    da.SelectCommand.Parameters.Add("@MemberId", SqlDbType.NVarChar).Value = memberId;
    da.SelectCommand.Parameters.Add("@ThirdName", SqlDbType.NVarChar).Value = thirdName;

    ds.Clear();
    da.Fill(ds);
    return ds;
}

it work good in localhost but when i call it in the php :

<?php
$wsdlUrl = "http://xxxx/WS/WebService.asmx?WSDL";  
$client = new soapclient($wsdlUrl);
$params = array('memberId' => 'W1100045','thirdName' => 'Ali');              
$result = $client->GetMembers($params);
$echoText = '';
if (is_null($result->GetMembersResult))
{
   echo "no result";
}
else
{
  echo $result->GetMembersResult;
}
?>

this error appear : Catchable fatal error: Object of class stdClass could not be converted to string on line 23

what is the problem and how can i solve this problem ?

शेखर
  • 17,412
  • 13
  • 61
  • 117
user1045265
  • 55
  • 1
  • 8
  • 3
    Which line is line 23? I'd begin by looking there... – Grant Thomas Apr 15 '13 at 10:00
  • Well, your expectations may be wrong. A var_dump or print_r can shed light on what $result actually is, re-examing the wsdl could tell you why. – chandresh_cool Apr 15 '13 at 10:06
  • echo $result->GetMembersResult; this is the line 23 – user1045265 Apr 15 '13 at 10:11
  • Shouldn't that be a function - `$result->GetMembersResult();`? It's being used like property – codingbiz Apr 15 '13 at 10:26
  • 2
    Error says you're trying to print a string while the variable is an object. As @chandresh_cool says, use `var_dump` or `print_r` to see the object and its properties. Also relevant: [Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World](http://www.hanselman.com/blog/ReturningDataSetsFromWebServicesIsTheSpawnOfSatanAndRepresentsAllThatIsTrulyEvilInTheWorld.aspx). Also duplicate of [Object of class stdClass could not be converted to string](http://stackoverflow.com/questions/3607550/object-of-class-stdclass-could-not-be-converted-to-string) – CodeCaster Apr 15 '13 at 10:26
  • how can i replace dataset with array – user1045265 Apr 15 '13 at 22:26

0 Answers0