Call WSDL Operation with SoapClient::__soapCall()

This section provides a tutorial example on how to call an operation defined in a WSDL document using the __soapCall(operation_name,...) function.

Instead of calling the WSDL operation as a SoapClient object function, you can also invoke the WSDL operation with the SoapClient::__soapCall() function:

Here a good example of a client program, NumberConversionCallSoap.php, on how to call an WSDL operation with the SoapClient::__soapCall() function. The NumberConversion Web service and its WSDL document are provided by dataaccess.com.

<?php 
# NumberConversionSoapCall.php
# Copyright (c) 2007 HerongYang.com. All Rights Reserved.
#
   $client = new SoapClient
("https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL");
   $operation = "NumberToWords";
   $inputs = array('ubiNum'=>202);
   $args = array($inputs);
   $result = $client->__soapCall($operation, $args);

   echo("Operation: $operation\n");
   echo("Arguments:\n");
   var_dump($args);
   echo("Result:\n");
   var_dump($result);
?>

When running it, I am getting:

herong> php NumberConversion.php

Operation: NumberToWords

Arguments:
array(1) {
  [0]=>
  array(1) {
    ["ubiNum"]=>
    int(202)
  }
}

Result:
object(stdClass)#2 (1) {
  ["NumberToWordsResult"]=>
  string(20) "two hundred and two "
}

Good. I am getting the same result. Note that input parameters must wrapped in nested arrays.

Table of Contents

 About This Book

 Introduction to Web Service

 Introduction to SOAP (Simple Object Access Protocol)

 SOAP Message Structure

 SOAP Message Transmission and Processing

 SOAP Data Model

 SOAP Encoding

 SOAP RPC Presentation

 SOAP Properties Model

 SOAP MEP (Message Exchange Patterns)

 SOAP HTTP Binding

 SOAP PHP Implementations

PHP SOAP Extension Client Programs

 PHP SOAP Extension Functions for Client Programs

 Calling WSDL Operation Directly

Call WSDL Operation with SoapClient::__soapCall()

 Dumping SOAP Request and Response

 Call WSDL Operation with SoapClient::__doRequest()

 PHP SOAP Extension Server Programs

 PHP SOAP Web Service Example - getTemp

 SOAP Perl Implementations

 Perl SOAP::Lite - SOAP Server-Client Communication Module

 Perl Socket Test Program for HTTP and SOAP

 Perl SOAP::Lite for NumberToWords SOAP 1.1 Web Service

 Perl SOAP::Lite for SOAP 1.2 Web Services

 Perl SOAP::Lite for WSDL

 Python SOAP Client: Zeep

 SOAP Java Implementations

 Java Socket and HttpURLConnection for SOAP

 SAAJ - SOAP with Attachments API for Java

 SoapUI - SOAP Web Service Testing Tool

 WS-Security - SOAP Message Security Extension

 WS-Security X.509 Certificate Token

 Perl SOAP::Lite for GetSpeech SOAP 1.1 Web Service

 Perl SOAP::Lite 0.710 for SOAP 1.2 Web Services

 Perl SOAP::Lite 0.710 for WSDL

 Web Services and SOAP Terminology

 Archived Tutorials

 References

 Full Version in PDF/EPUB