Hey

When I try to interpret thru PHP, a Java web service that returns a boolean type, this error (more like a warning) pops up:

Notice: Object of class stdClass could not be converted to int in C:\testing\page.php on line 29

It seems this is something PHP related.

How can I make the PHP page understand true and false? Or at least recieve true or and false, if neccesary convert them to 1 and 0 and understand that? No, I cant change the web service to send 1 or 0, sorry.

Recommended Answers

All 8 Replies

Member Avatar for diafol

Perhaps we'd have a chance of helping you if you posted your code.

Perhaps we'd have a chance of helping you if you posted your code.

My apoligies

<?php
                $servicio="http://127.0.0.1:8080/axis2/services/WebService?wsdl"; //FAKE IP
                //Parameters
                $name="948318157"; //INTEGER
                $email="someemail@domain.com";
                $id="2398";
                $product="12";
                $coor=$_POST["coord"];
                $product="43634"; //INTEGER
                $customerEmail="someotheremail@domain.com";
                $customerName="cust";

                //YES, I know there are 2 variables that are named product 
                //which overwrite each other. 

                $parametros = array();
                $parametros['id'] = $name;
                $parametros['email'] = $email;
                $parametros['id_ped'] = $id;
                $parametros['id_pro'] = $product;
                $parametros['coor'] = $coor;
                $parametros['type'] = $product;
                $parametros['email_c'] = $customerEmail;
                $parametros['name_c'] = $customerName;

                $client = new SoapClient($servicio, $parametros);
                $result = $client->datawebser($parametros);//web service method
                echo ('<html><head><title>Res:</title></head><body>');
                echo ('result es ' + $result);

                ech ('<br />');
                if ($result==1)
                {
                    echo ('worked!');
                }
                else
                {
                    echo ('something went wrong');
                }
                echo ('</body></html>');
?>

There is the code :) I hope it helps out.

You have to use . (dot) for concatenation and not +.

So this:

echo ('result es ' + $result);

Should be

echo ('result es '. $result);

You have to use . (dot) for concatenation and not +.

So this:
1.echo ('result es ' + $result);
Should be
1.echo ('result es '. $result);

Well, irrelevent of that small sintaxis error, that line says "result is " and followed by a blank meaning that the blank cannot be read (which is the topic at hand :P )

What if you add exception handling, something like this:

try {
    $client = new SoapClient($servicio, $parametros);
    $result = $client->datawebser($parametros);
    print_r($result);
}
catch (Exception $e) { 
    echo '<h2>Exception Error!</h2>'; 
    echo $e->getMessage(); 
}

Do you see an exception message?

Added it. The output is:

stdClass Object ( [return] => 1 )

Meaning that it does NOT enter the catch. Simply prints out the array.

Have you tried:
echo $result->return;

Nope but that worked :) Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.