Friday, March 21, 2014

A Complete PHP SOAP Client Example

This is a complete PHP SOAP Client example where we consumed the web services we developed here. You can also take a look at how we generated the WSDL file for the web service.



The code below started by disabling WSDL cache and defined the wsdl location. We also specify the soap server location. This parameter is optional if you define the soap server location in the wsdl file. We then, instantiate the PHP SOAP Client object by passing it the relevant parameters. We call the boom() method from the soap server class with two parameters; first->"PHP SOAP", and last->"Tutorial". The WSDL Tutorial, explained how we created these parameters. We accessed the value of the returned complex type, boomResponse, by calling the variable, "return". Note that "return" is a parameter of type, boomResponse. Check the server example for more information. Optionally, you can call __getLastRequest() and __getLastResponse() on the soap client object to see the last SOAP request and response respectively.











Your comments and suggestions are welcome

13 comments:

  1. Your post just solved my problem. Thanks

    ReplyDelete
  2. Thanks so much for your clear post

    ReplyDelete
  3. This solved my issue .. great post!!

    ReplyDelete
  4. I cant see the sample code you are referring to please.

    ReplyDelete
    Replies
    1. Hi, the sample codes are just right below the tutorial. It may be a browser issue. Try a different one.

      Delete
  5. Hi Gabriel, I cant find the sample codes you are referring to. Do i need to sign up anywhere to view your examples?

    ReplyDelete
    Replies
    1. Hello TG, the sample codes are just right below the tutorial. It may be a browser issue. Try a different one.

      Delete
  6. Hello TG, the sample codes are just right below the tutorial. It may be a browser issue. Try a different one.

    ReplyDelete
  7. Great post with structure and clarity !

    ReplyDelete
  8. I did copy server and client code. server_test.php and client test.php I get this error

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'ExampleClassWS.wsdl' : failed to load external entity "ExampleClassWS.wsdl"
    1) both are in the same directory
    2) Soap Client enabled
    Soap Server enabled

    any Idea??

    ReplyDelete
  9. Hi there, I found your web site by way of Google at the same time
    as searching for a related topic, your website came up,
    it appears great. I have bookmarked it in my google bookmarks.

    Hi there, just changed into aware of your blog via Google,
    and found that it's really informative. I'm gonna be careful for brussels.
    I'll be grateful in the event you proceed this in future. Numerous folks might be benefited out of your writing.

    Cheers!

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...