phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Services - WSDL: Sample WSDL Document

Tag: web services, wsdl   Category: PHP Application
post: 10 Apr 2008 read: 971


PHP Web Services Using WSDL Step By Step Tutorial - Part 2: Now, we will look sample WSDL document. In this sample, we want to load text from server. User put their name (such as "Aqila"), then server return text "hello, Aqila". Our web services named "hello". Below our WSDL for hello:

<?xml version="1.0"?>
<definitions name="HelloWorld" targetNamespace="urn:HelloWorld" xmlns:tns="urn:HelloWorld"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Hello">
      <xsd:element name="getName" type="xsd:string" />
	  <xsd:element name="HelloResponse" type="xsd:string" />	 	  
	</xsd:schema>			
  </types>
  
  <message name="doHello">
    <part name="yourName" type="tns:getName" />
  </message>
  
  <message name="doHelloResponse">
    <part name="return" type="tns:HelloResponse" />
  </message>  
  
  <portType name="HelloPort">
    <operation name="doHello">
	  <input message="tns:doHello" />
	  <output message="tns:doHelloResponse" />
	</operation>
  </portType>
  
  <binding name="HelloBinding" type="tns:HelloPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
	  <operation name="doHello">
	    <soap:operation soapAction="urn:HelloAction" />
		<input>
		  <soap:body use="encoded" namespace="urn:Hello" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />		  
		</input>
		<output>
		  <soap:body use="encoded" namespace="urn:Hello" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />		  
		</output>
	  </operation>
  </binding>
  
  <service name="HelloService">
    <port name="HelloPort" binding="tns:HelloBinding">
	  <soap:address location="http://localhost/test/wsdl/hello_server.php" />
	</port>
  </service>
    
</definitions>

Create a file named "hello.wsdl" within www/test/wsdl. Enter code above.

From the code, you can see structure like previous article.



Series this article:
Webservices - WSDL: Anatomy of WSDL Document
Web Services - WSDL: Sample WSDL Document
Web Services - WSDL: Types
Web Services - WSDL: Messages
Web Services - WSDL: Port Types
Web Services - WSDL: Bindings
Web Services - WSDL: Service
Web Services - WSDL: Creating SOAP Server
Web Services - WSDL: Testing with SOAP Client

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

1 Responses to Web Services - WSDL: Sample WSDL Document:

Thank you for posting this tutorial. It is the first tutorial I have seen that gives a basic example of the wsdl doc, server php, and client php. It helped to solidify my understanding of the topic. Thanks!

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting