WSDL web services example php.

In my previous article, i explain the thrmo of the web services using WSDL in php. Now, here i give the example of the WSDL web services, so you should be more clear on the php web services examples.

Below is the complete XML code for helloword wsdl web services in which we load text from the server. here user give there name as input (like php freelancer), while server give the output “hello, php freelancer”.

<?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>

What is web services? what is SOAP and WSDL in php?

Below is some question in your mind when you talking about php web services.

What is web services?
what is SOAP?
What is WSDL?
web services in php

Web services is a big keyword when any developer heard, but actually web services are very simple and very easy to understand and implement.

You can develop php web services using SOAP and WSDL.

Here, i will explain you about the WSDL, full name of WSDL is Web Services description Language. its is basically a XML document format used to describe the web service. when we need to develop any web service, we need to define it in the same format which shows how to web service access, how it perform the operation and the also show that how you can passed the message and what is structure of the message. Below is the WSDL XML format which will help you to understand in more details.

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    Here you need to write definition of types used in WSDL
  </types>
 
  <message>
    Here you need to write abstract definition of the data being transmitted
  </message>
 
  <portType>
    Here you need to write a set of abstract operations referring to input and output messages
  </portType>
 
  <binding>
    Here you need to write concrete protocol and data format specification
  </binding>
 
  <service>
    Here you need to write specifies locations and bindings for a service
  </service>
</definitions>

I know, after looking this format, you worried about the middle part of each xml tags, I mention this format here and skip the middle part of XML tags because this is thrmo for any web service based on WSDL. In my next post i will explain WSDL web services in more details.