Creating a SOAP Client
From Rosetta Code
Programming Task
This is a programming task. It lays out a problem which Rosetta Code users are encouraged to solve, using languages they know.
Contents |
[edit] ActionScript
Works with: ActionScript version 3.0
import mx.rpc.soap.WebService; import mx.rpc.events.ResultEvent; var ws:WebService = new WebService(); ws.wsdl = 'http://example.com/soap/wsdl'; ws.soapFunc.addEventListener("result",soapFunc_Result); ws.anotherSoapFunc.addEventListener("result",anotherSoapFunc_Result); ws.loadWSDL(); ws.soapFunc(); ws.anotherSoapFunc(); // method invocation callback handlers private function soapFunc_Result(event:ResultEvent):void { // do something } private function anotherSoapFunc_Result(event:ResultEvent):void { // do another something }
[edit] ColdFusion
<cfset client = createObject("webservice","http://example.com/soap/wsdl")>
<cfset result = client.soapFunc("hello")>
<cfset result = client.anotherSoapFunc(34234)>
[edit] Perl
Library: SOAP::Lite
use SOAP::Lite;
print SOAP::Lite
-> service('http://example.com/soap/wsdl')
-> soapFunc("hello");
print SOAP::Lite
-> service('http://example.com/soap/wsdl')
-> anotherSoapFunc(34234);
[edit] PHP
Works with: PHP version 5.0.0+
<?php
//load the wsdl file
$client = new SoapClient("http://example.com/soap/definition.wsdl");
//functions are now available to be called
$result = $client->soapFunc("hello");
$result = $client->anotherSoapFunc(34234);
//SOAP Information
$client = new SoapClient("http://example.com/soap/definition.wsdl");
//list of SOAP types
print_r($client->__getTypes());
//list if SOAP Functions
print_r($client->__getFunctions());
?>
[edit] Python
Works with: Python version 2.4 and 2.5
from SOAPpy import WSDL
proxy = WSDL.Proxy("http://example.com/soap/wsdl")
result = proxy.soapFunc("hello")
result = proxy.anotherSoapFunc(34234)
Note: SOAPpy is a third-party module and can be found at Python Web Services
[edit] VBScript
Dim client
Dim result
Set client = CreateObject("MSSOAP.SoapClient")
client.MSSoapInit "http://example.com/soap/wsdl"
result = client.soapFunc("hello")
result = client.anotherSoapFunc(34234)
[edit] Visual Objects
LOCAL oSoapClient AS OLEAUTOOBJECT
LOCAL cUrl AS STRING
LOCAL uResult AS USUAL
oSoapClient := OLEAutoObject{"MSSOAP.SoapClient30"}
cUrl := "http://example.com/soap/wsdl"
IF oSoapClient:fInit
oSoapClient:mssoapinit(cUrl,"", "", "" )
uResult := oSoapClient:soapFunc("hello")
uResult := oSoapClient:anotherSoapFunc(34234)
ENDIF

