Software Development

Simple PHP SOAP Client Example


This article demonstrates how to create an SOAP client using PHP and consume a SOAP-based web service


Hardware Environment


Software Environment

  • Windows 7 Professional SP1
  • PHP 5.5.9 / Zend Engine v2.5.0

Find a free Web Service Online

First, find a free web service online to test. For this post, the StockQuote service is used which is available on



Open the WSDL on the browser.




A new tab will open showing the content of WSDL we chose.



Next, we look for a SOAP-based operation and look at its input and output messages. There are 3 operations in this WSDL but we are only interested “GetQuote” under the “StockQuoteSoap” portType.



GetQuote operation


Using PHP


Then, we look for the element  “GetOute” used in the “GetQuoteSoapIn”. It represents the “parameters” that we need to pass to get some meaningful output. Also, take note of the “GetQuoteResult” within the “GetQuoteResponse” element. We will use that to read the value from the web service response in PHP.


With those information, we can know code our PHP client to execute a SOAP operation.

Sample Output




You Might Also Like