0

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.

4
Contributors
8
Replies
11
Views
5 Years
Discussion Span
Last Post by riahc3
0

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

0

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.

0

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

So this:

echo ('result es ' + $result);

Should be

echo ('result es '. $result);

Edited by vibhaJ

0

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 )

0

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?

0

Added it. The output is:

stdClass Object ( [return] => 1 )

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

0

Have you tried:
echo $result->return;

Nope but that worked :) Thank you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.