This article describes the new SOAP extension for PHP. It is intended for PHP developers who want to write their own Web Services servers, or use SOAP to access existing ones. It assumes some familiarity with Web Services, SOAP, and WSDL (Web Services Description Language).
Let’s try to write our own SOAP Web service that will do the same as the XMethods “Delayed Stock Quote” service.
The first task is to create a WSDL document describing our service in a format that client requests will understand. This requires minor modifications to the original document taken from the Xmethods site, so we’ll start by taking a close look at that file.
The message section defines two messages. The first is getQuoteRequest, which is a request to relay the getQuote message and takes one string parameter called symbol. The other is getQuoteResponse, which is a response to the getQuote message, containing one float value, named Result.
The portType section defines one operation, getQuote, which describes which of the messages listed in the message section will be used to transmit the request and response.
The binding section defines how the messages must be transmitted and encoded. Here it tells us that we will be sending an RPC request using SOAP encoding across HTTP. It also specifies namespace and value of the SOAPAction header for the getQuote method.
Lastly, the service section defines the endpoint URL where the service is running. Example 3 (stockquote.wsdl)