-1

Basic PHP function:

//SOAP CALL
function sayHello(){
    $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL');
    $response = $client->glassfishHello();
    return $response;   
}

(later I call sayHello() as a String and that is where the error is)

Basic EJB provided JAX-WS:

@WebService
@Stateless
public class MyClass{
  @WebMethod(operationName="glassfishHello")
  public String glassfishHello(){
    return "Hello from GlassFish";
  }
}

I must be missing something very simple but after exhausting google and other options I cannot find as simple an example as I need to understand this.

My Php has the error: recoverable fatal error: Object of class stdClass could not be converted to string in.. etc.

So there must be something in PHP that I must do to parse the response from the WSDL.

Thank you! (I can post the WSDL or any other resources) Yes I do have SOAP enabled and working.


Yes my problem is what type of object is being returned. I want my sayHello() function to return a String. If i cast $response = (string).. then I have the error there.


ANSWER: I knew it was simple, just a dumb PHP mistake, it has been too long since I used PHP last:

//SOAP CALL
function sayHello(){
    $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL');
    $response = (array) $client->glassfishHello();      
    return $response['return'];
}
Quinma
  • 1,436
  • 2
  • 17
  • 39
  • http://stackoverflow.com/questions/5032687/php-catchable-fatal-error-object-of-class-stdclass-could-not-be-converted-to-s – kosa May 11 '12 at 18:54
  • `$response` will be an object not a string. I suspect you are treating the return value of `sayHello()` as a string, in the code that you haven't shown. – MrCode May 11 '12 at 19:01
  • You know that it's perfectly acceptable to answer your own question? – Kev May 12 '12 at 16:29
  • Yes I do know but I needed to wait 12 hours before I did so since I have a low reputation.. – Quinma May 14 '12 at 17:26

1 Answers1

0

I knew it was simple, just a dumb PHP mistake, it has been too long since I used PHP last:

//SOAP CALL
function sayHello(){
    $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL');
    $response = (array) $client->glassfishHello();      
    return $response['return'];
}
Quinma
  • 1,436
  • 2
  • 17
  • 39