PHP Classes

File: example_weather_proxy_call2.php

Recommend this page to a friend!
  Classes of Przemek Berezowski   SOAP Proxy   example_weather_proxy_call2.php   Download  
File: example_weather_proxy_call2.php
Role: Example script
Content type: text/plain
Description: More advanced usage
Class: SOAP Proxy
Generate code to access SOAP services from an WSDL
Author: By
Last change: Comment edit
Date: 13 years ago
Size: 1,278 bytes
 

Contents

Class file image Download
<?php
include('src_config.php');

require(
'SoapProxy.php');
require(
'output/WeatherService.php');


//add soap class mapping to catch response in own class
$opts['classmap'] = array (
   
'GetWeatherResponse' => 'MyResponse',
);


/**
 * Extended GetWeatherResponse to provide
 * example methods in ws response class
 *
 * @author Przemek Berezowski
 *
 */
class MyResponse extends WeatherParam_GetWeatherResponse {
   
   
/**
     * This is an example method to print ws answer in reverse order
     */
   
public function exampleMethod() {
        return
strrev($this->GetWeatherResult);
    }
   
}

//create service instance
$service = new WeatherService($wsdl, $opts);
//create and setup parameter for call
$param = new WeatherParam_GetWeather();
$param->City = 'New York';

//run ws method
$result = $service->GetWeather($param);

//run a method in response class
echo 'Result is: '.$result->GetWeatherResult;
echo
'<br />';
echo
'Result in reverse order is: '.$result->exampleMethod();

echo
"<hr />";
echo
'Soap requst<br />';
//printing soap request
highlight_string($service->soapClient->__getLastRequest());

echo
"<hr />";
echo
'Soap response<br />';
//printing soap response
highlight_string($service->soapClient->__getLastResponse());