us/dist/eg/clients/GeoCoderPHP.wsdl'
server = WSDL.Proxy(wsdl_url)
# let's see what operations are supported
server.show_methods()
# geocode the Apress address
address = "2855 Telegraph Ave, Berkeley, CA"
result = server.geocode(location=address)
print "latitude and longitude: %s, %s" % (result[0]['lat'], result[0]['long'])
This produces the following output (edited for clarity):
Method Name: geocode_intersection
In #0: intersection ((u'http://www.w3.org/2001/XMLSchema', u'string'))
Out #0: results ((u'http://rpc.geocoder.us/Geo/Coder/US/',
u'ArrayOfGeocoderIntersectionResult'))
Method Name: geocode_address
In #0: address ((u'http://www.w3.org/2001/XMLSchema', u'string'))
Out #0: results ((u'http://rpc.geocoder.us/Geo/Coder/US/',
u'ArrayOfGeocoderAddressResult'))
Method Name: geocode
In #0: location ((u'http://www.w3.org/2001/XMLSchema', u'string'))
Out #0: results ((u'http://rpc.geocoder.us/Geo/Coder/US/',
u'ArrayOfGeocoderResult'))
latitude and longitude: 37.858276, -122.26007
Notice the reference to XML schema types in describing the location parameter for
geocode. The type definitions come, as one expects, from the WSDL document.
The concision of this code shows WSDL and SOAP in good light.
CHAPTER 7 ?– EXPLORING OTHER WEB APIS 189
USING SOAP FROM PHP
There are several choices of libraries for consuming SOAP in PHP:
??? NuSOAP (http://sourceforge.
Pages:
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333