SoapCall Multiple Parameter within same url name

$ID = isset($_GET['ID']) ? $_GET['ID'] : NULL;
$params = array(
    'getId1'=>array(
        "Id1"=>"$ID"
    ),
    'getId2'=>array(
        "Id2" => "$ID"
    )
);

$client = new SoapClient("http://example.com?wsdl");
 $result = $client->$params;
 
 if(!empty($result)){
     $ret = $result->contactId1;
      var_dump($ret);
 }  else {
     $ret = $result->contactId2;
      var_dump($ret);
  
}

I got NULL value for both ID.

Can some one help to look at my code, Thanks!

Ha…No one out there to help! Dissapointed, even paying customer! Will be cancel premium membership soon.

You are confused.

Most forum members are not employed by SitePoint and offer assistance voluntarily.

Anyway try putting the $client = $result = bit inside a try catch

try {
$client = new SoapClient("http://example.com?wsdl");
 $result = $client->$params;
}
catch (SoapFault $fault)
{
       echo "SOAP Fault: faultcode: " . $fault->faultcode . " faultstring: " . $fault->faultstring;
}

Thanks Greatlly appreciated it… I tried it and var_dump($result); Still giving me NULL value

Try changing

$ID = isset($_GET['ID']) ? $_GET['ID'] : NULL;

to

$ID = isset($_GET['ID']) ? $_GET['ID'] : 123;

and

if(!empty($result)){
     $ret = $result->contactId1;
      var_dump($ret);
 }  else {
     $ret = $result->contactId2;
      var_dump($ret);
}

to

 if(!empty($result)){
     $ret = $result->contactId1;
      var_dump($ret);
 }  else {
      var_dump($params); 
}

OMG! I love you till death. You are awesome! Thanks. It worked! SIr

:disappointed_relieved: oh no its not giving any value from Soap web services… only from array

array(2) { [“Id1”]=> array(1) { [“ID”]=> string(4) “90” } [“Id2”]=> array(1) { [“Id2”]=> string(4) “90” } }

What does the SOAP server and wsdl files’ code look like?

getSiteInfoById
Request 1–>
getId1?getId1

getWorkInfoById
Request 1–>
getId2 ? getId2

I would like to access both id within same like php?ID=1

Is this possible in php?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.