Consuming or Get Data From Wsdl Web Services

Published on : April 27, 2026

Author:

Category: Uncategorized


Consuming Wsdl Web services in Php

Before Start Wsdl service in php you must have common knowledge about some topics

  • Web service?

The term Web services describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone.
In common terms web service gives you information base on what you want. You have to asked the web service on standard way for some information then it gives you output.

  • What is Wsdl?

Wsdl is a web service which means Web Services Description Language. It is the standard format for describing a web service. It is work on cross platform and independent language.

wsdl-document-structure

Mainly Wsdl Developed by Microsoft and IBM, so Wsdl service creation and consuming is easy in .net environment and also it has strong field in java environment, but little difficult in php.

We can make a wsdl service in server by using many php library

  • 1. NuSOAP – SOAP Toolkit for PHP
  • 2. WSO2 Web Services Framework for PHP

And those library can also use for parsing or getting data or consuming web service. In Latest Version of php there is soap based web services can easily consume or parse by Php soap client.

Note:

For Creating a web service in server in php we used soap library. And in client side we used php default library to parse or consuming web services.

http://www.w3schools.com/webservices/tempconvert.asmx?wsdl
So Look Over How To Consume The Web Services
Before consuming the web services first look over how the wsdl are

[code language=”xml”]
<definitions>

<types>
data type definitions……..
</types>

<message>
definition of the data being communicated….
</message>

<portType>
set of operations……
</portType>

<binding>
protocol and data format specification….
</binding>

</definitions>

<message name="getTermRequest">
<part name="term" type="xs:string"/>
</message>

<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>

<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
[/code]

Example Of A Service That We Want To Consume. If You Create The Services then you know the method and parameter of the method then you just can call them if you don’t know then first you have to know what are the method available and what are the type of parameter in those method

http://www.w3schools.com/webservices/tempconvert.asmx?wsdl

[code language=”php”]
<?php
$client = new SoapClient("http://www.w3schools.com/webservices/tempconvert.asmx?wsdl");
//To See Available Method Or Operation
$type = $client->__getTypes();
var_dump($type);
?>
[/code]

getting-function-or-operation-of-wsdl-document

[code language=”php”]
<?php
$client = new SoapClient("http://www.w3schools.com/webservices/tempconvert.asmx?wsdl");
//To See Available Method Or Operation
$function = $client->__getFunctions();
var_dump($function);
?>
[/code]

types-and-details-of-a-wsdl-file

Now Getting All Function and type we will consuming just one method for example

[code language=”php”]
<?php
$client = new SoapClient("http://www.w3schools.com/webservices/tempconvert.asmx?wsdl");
$result = $client->FahrenheitToCelsius(array(‘Fahrenheit’ => ’10’));
var_dump($result);
?>
[/code]

output of wsdl file