Created
December 17, 2009 17:30
-
-
Save ryanfitz/258888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys | |
import os | |
from suds.client import Client | |
from suds.wsse import * | |
import logging | |
USERNAME = '[email protected]' | |
PASS = 'optimize' | |
URL = 'http://localhost:20500/ConstantsServiceVersionOne?wsdl' | |
SHOULD_DEBUG = False | |
def main(): | |
if SHOULD_DEBUG: | |
logging.basicConfig(level=logging.INFO) | |
logging.getLogger('suds.client').setLevel(logging.DEBUG) | |
logging.getLogger('suds.transport').setLevel(logging.DEBUG) | |
client = Client(URL) | |
client.set_options(wsse=create_security_header()) | |
values = client.factory.create('GeographicRegionField2ArrayOfStringMap.entry.value') | |
values.string = ['1'] | |
# print values | |
entry = client.factory.create('GeographicRegionField2ArrayOfStringMap.entry') | |
entry.key = 'GEOGRAPHIC_REGION_ID' | |
entry.value = values | |
# print entry | |
query = client.factory.create('GeographicRegionField2ArrayOfStringMap') | |
query.entry = [entry] | |
# print query | |
print """\n\n------------- client return ----------------\n\n""" | |
result = client.service.getGeographicRegions(query) | |
print result | |
def create_security_header(): | |
security = Security() | |
token = UsernameToken(USERNAME, PASS) | |
token.setnonce() | |
token.setcreated() | |
security.tokens.append(token) | |
return security | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment