Creating a SOAP server with the native SOAP extension is easier than you think. Although several server-specific methods are provided with the SOAP extension, only three methods are required to create a complete WSDL-enabled server. This section introduces these and other methods, guiding you through the process of creating a functional SOAP server as the section progresses. The section “SOAP Client and Server Interaction” offers a complete working example of the interaction between a WSDL-enabled client and server created using this extension. To illustrate this, the examples in the remainder of this chapter refer to Listing 20-6, which offers a sample WSDL file. Directly following the listing, a few important SOAP configuration directives are introduced that you need to keep in mind when building SOAP services using this extension. Listing 20-6. A Sample WSDL File (boxing.wsdl) <?xml version="1.0" ?> <message name="getQuoteRequest"> <message name="getQuoteResponse"> <portType name="QuotePortType"> <binding name="QuoteBinding" type="tns:QuotePortType"> <service name="boxing"> TheSoapServer()constructor instantiates a new instance of theSoapServer class in WSDL or non-WSDL mode. Its prototype looks like this: object SoapServer->SoapServer(mixed wsdl [, array options]) If you require WSDL mode, you need to assign thewsdl parameter the WSDL file’s location, or else set it toNULL. The optionaloptionsparameter is an array used to set the following options:
The following example creates aSoapServer object referencing theboxing.wsdlfile: $soapserver = new SoapServer("boxing.wsdl"); If the WSDL file resides on another server, you can reference it using a valid URI: $soapserver = new SoapServer("http://www.example.com/boxing.wsdl"); Next, you need to export at least one function, a task accomplished using theaddFunction()method, introduced next. Note If you’re interested in exposing all methods in a class through the SOAP server, use the methodsetClass(), introduced later in this section.
blog comments powered by Disqus |
|
|
|
|
|
|
|