Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1
CHAPTER 19 ■ INTRODUCTION TO WEB SERVICES WITH SOAP^287

Port: This combines a binding with an endpoint and provides the URL where the service
can be located. The port is the actual fully qualified URL to the PHP script that will host
your SOAP server.

Service: This defines a collection of ports that make up your web service.

A WSDL File.


Ignoring any purpose, which will come later, let’s look at a WSDL file created for a method
called demo that takes exactly one string parameter and returns exactly one string value, running on
http://localhost/service.php. Listing 19-1 shows this WSDL file.

■Note URIs in WSDL files are case-sensitive. http://localhost/demo is not the same as http://
localhost/Demo.

Listing 19-1. A Sample WDSL File (demo.wsdl)

<?xml version ="1.0" encoding ="UTF-8" ?>
<definitions name="demo"
targetNamespace="http://localhost/demo"
xmlns:tns="http://localhost/demo"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/">

<message name="DemoRequest">
<part name="param1" type="xsd:string" />
</message>

<message name="DemoResponse">
<part name="Result" type="xsd:string" />
</message>

<portType name="DemoPortType">
<operation name="Demo">
<input message="tns:DemoRequest" />
<output message="tns:DemoResponse" />
</operation>
</portType>

<binding name="DemoBinding" type="tns:DemoPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="Demo">

McArthur_819-9.book Page 287 Friday, February 29, 2008 8:03 AM

Free download pdf