473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Accessing USGS Web Service Using Python

Hi!

** Accessing the USGS Web Service Using Python **

I am trying to access the US Geological Survey's gazetteer SOAP web service
using Python to find the locations of all the places with the name
'Alexandria.' I tried to keep this simple by putting a soap message in a
string and sending the request using httplib.

I am receiving the following error message.

Reply: 400 Bad Request
<h1>Bad Request</h1>
`
I apologize in advance if this is not the correct approach.

--------------------------
Here is my code ...

import httplib

# soap string to send
soapstr = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<searchName xmlns="http://gisdata.usgs.net/XMLWebServices/">
<PlaceName>Alexandria</PlaceName>
<PlaceType>ppl</PlaceType>
<inNumRecords>10</inNumRecords>
<inFirstRecord>1</inFirstRecord>
</searchName>
</soap:Body>
</soap:Envelope>"""

# send request
h = httplib.HTTP('gisdata.usgs.net')
h.putrequest("POST", "/XMLWebServices/TNM_Gazetteer_Service.asmx HTTP/1.1")
h.putheader("Content-Type", "text/xml; charset=utf-8")
h.putheader("Content-Length", str(len(soapstr)))
h.putheader ("SOAPAction",
"http://gisdata.usgs.net/XMLWebServices/searchName")
h.endheaders()
# send soap string
h.send(soapstr)

# get the HTTP response
reply, message, headers = h.getreply()
print "Reply: ", reply, message
# print the results
result = h.getfile().read()
print result
---------------

Here is the guidance from the USGS Web Site
http://gisdata.usgs.net/XMLWebServic...?op=searchName

The following is a sample SOAP request. The placeholders shown need to be
replaced with actual values.

POST /XMLWebServices/TNM_Gazetteer_Service.asmx HTTP/1.1
Host: gisdata.usgs.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://gisdata.usgs.net/XMLWebServices/searchName"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<searchName xmlns="http://gisdata.usgs.net/XMLWebServices/">
<PlaceName>string</PlaceName>
<PlaceType>string</PlaceType>
<inNumRecords>string</inNumRecords>
<inFirstRecord>string</inFirstRecord>
</searchName>
</soap:Body>
</soap:Envelope>

---------------

Thank you!
Jul 28 '06 #1
0 1491

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
1
by: Eirik Brattbakk | last post by:
Hi I have some problems accessing a soap service made in c# using an ATL/MFC client over SSL. I have tried both CSoapMSXMLInetClient and CSoapWininetClient as template arguments with my stub...
3
by: Jim Lewis | last post by:
I have read several things that state accessing a Web Service through a Query String should work. However, when I try to execute http://localhost/webservice1/service1.asmx/HelloWorld I get the...
4
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.