"SOAP Version 1.2 provides the definition of
the XML-based information which can be used for exchanging structured
and typed information between peers in a decentralized, distributed environment."
[W3C]
- SOAP is a communication protocol
- SOAP is for communication between applications
- SOAP is a format for sending messages
- SOAP is designed to communicate via Internet
- SOAP is platform independent
- SOAP is language independent
- SOAP is based on XML
- SOAP is simple and extensible
- SOAP allows you to get around firewalls
- SOAP will be developed as a W3C standard
from suds.client import Client
client = Client('http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl')
print
client.GetStockQuote('AMZN')
client = Client('http://www.restfulwebservices.net/wcf/CurrencyService.svc?wsdl')
print
client.service.GetConversionRate('USD', 'CAD')
print client.service.GetConversionRate('CAD',
'JPY')
client = Client('http://webservices.tekever.eu/ip2pais/?wsdl ')
print
client.service.IP2Pais('132.206.14.122')
Python (2.6) example with suds-0.3.7
from suds.client import Client
client = Client("http://www.ecubicle.net/iptocountry.asmx?wsdl")
result = client.service.FindCountryAsString("132.216.177.140")
print
result
==============================
Python (2.0) examples (with SOAP.py):
import SOAP
from SOAPpy import SOAPProxy
====
server = SOAP.SOAPProxy("http://services.xmethods.net/soap")
print server._ns("urn:xmethods-delayed-quotes").getQuote(symbol
= "AMZN")
====
server = SOAP.SOAPProxy("http://services.xmethods.net/soap")
print server._ns("urn:xmethods-CurrencyExchange").getRate(country1="usa",
country2="canada")
print server._ns("urn:xmethods-CurrencyExchange").getRate(country1="usa",
country2="japan")
====
server = SOAP.SOAPProxy("http://services.xmethods.net:80/perl/soaplite.cgi")
print server._ns("urn:xmethodsBabelFish").BabelFish(translationmode="en_fr",
sourcedata="soap is good for translation")
====
A simple "Hello World" http SOAP server:
import SOAPpy
def hello():
return "Hello World"
server = SOAPpy.SOAPServer(("localhost", 8080))
server.registerFunction(hello)
server.serve_forever()
And the corresponding client:
import SOAPpy
server = SOAPpy.SOAPProxy("http://localhost:8080/")
print server.hello()
|