Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
added environ var FUELSDK_WSDL_FILE_LOCAL_LOC to specify path/file to…
Browse files Browse the repository at this point in the history
… use in place of default ExactTargetWSDL.xml location. Needed when running multiple instances on same server that connect to different wsdl endpoints (s4 vs s6 vs etc).
  • Loading branch information
Randy Shults committed Apr 4, 2014
1 parent 54fe66c commit 8601135
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
26 changes: 19 additions & 7 deletions FuelSDK/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,24 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):

if params is not None and 'authenticationurl' in params:
self.auth_url = params['authenticationurl']
if config.has_option('Web Services', 'authenticationurl'):
elif config.has_option('Web Services', 'authenticationurl'):
self.auth_url = config.get('Web Services', 'authenticationurl')
elif 'FUELSDK_AUTH_URL' in os.environ:
self.auth_url = os.environ['FUELSDK_AUTH_URL']
else:
self.auth_url = 'https://auth.exacttargetapis.com/v1/requestToken?legacy=1'

self.wsdl_file_url = self.load_wsdl(wsdl_server_url, get_server_wsdl)

if params is not None and "wsdl_file_local_loc" in params:
wsdl_file_local_location = params["wsdl_file_local_loc"]
elif config.has_option("Web Services", "wsdl_file_local_loc"):
wsdl_file_local_location = config.get("Web Services", "wsdl_file_local_loc")
elif "FUELSDK_WSDL_FILE_LOCAL_LOC" in os.environ:
wsdl_file_local_location = os.environ["FUELSDK_WSDL_FILE_LOCAL_LOC"]
else:
wsdl_file_local_location = None

self.wsdl_file_url = self.load_wsdl(wsdl_server_url, wsdl_file_local_location, get_server_wsdl)

## get the JWT from the params if passed in...or go to the server to get it
if(params is not None and 'jwt' in params):
decodedJWT = jwt.decode(params['jwt'], self.appsignature)
Expand All @@ -104,17 +113,20 @@ def __init__(self, get_server_wsdl = False, debug = False, params = None):
self.refresh_token()


def load_wsdl(self, wsdl_url, get_server_wsdl = False):
def load_wsdl(self, wsdl_url, wsdl_file_local_location, get_server_wsdl = False):
"""
retrieve the url of the ExactTarget wsdl...either file: or http:
depending on if it already exists locally or server flag is set and
server has a newer copy
"""
path = os.path.dirname(os.path.abspath(__file__))
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
if wsdl_file_local_location is not None:
file_location = wsdl_file_local_location
else:
path = os.path.dirname(os.path.abspath(__file__))
file_location = os.path.join(path, 'ExactTargetWSDL.xml')
file_url = 'file:///' + file_location

if not os.path.exists(file_location): #if there is no local copy then go get it...
if not os.path.exists(file_location) or os.path.getsize(file_location) == 0: #if there is no local copy or local copy is empty then go get it...
self.retrieve_server_wsdl(wsdl_url, file_location)
elif get_server_wsdl:
r = requests.head(wsdl_url)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ You must configure your access tokens and details for the Fuel SDK in one of the
* `FUELSDK_APP_SIGNATURE`
* `FUELSDK_DEFAULT_WSDL`
* `FUELSDK_AUTH_URL`
* `FUELSDK_WSDL_FILE_LOCAL_LOC`

Edit `config.python` or declare environment variables so you can input the ClientID and Client Secret values provided when you registered your application. If you are building a HubExchange application for the Interactive Marketing Hub then, you must also provide the Application Signature (`appsignature` / `FUELSDK_APP_SIGNATURE`).
The `defaultwsdl` / `FUELSDK_DEFAULT_WSDL` configuration must be [changed depending on the ExactTarget service](https://code.exacttarget.com/question/there-any-cetificrate-install-our-server-access-et-api "ExactTarget Forum").
The `authenticationurl` / `FUELSDK_AUTH_URL` must also be [changed depending on service](https://code.exacttarget.com/question/not-able-create-accesstoken-when-clientidsecret-associated-preproduction-account "ExactTarget Forum").
The `wsdl_file_local_loc` / `FUELSDK_WSDL_FILE_LOCAL_LOC` allows you to specify the full path/filename where the WSDL file will be located on disk, if for instance you are connecting to different endpoints from the same server.

If you have not registered your application or you need to lookup your Application Key or Application Signature values, please go to App Center at [Code@: ExactTarget's Developer Community](http://code.exacttarget.com/appcenter "Code@ App Center").

Expand Down
3 changes: 2 additions & 1 deletion config.python.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ appsignature: none
clientid: XXXXXXXXXXXXXXXXXXXXXXXX
clientsecret: XXXXXXXXXXXXXXXXXXXXXXXX
defaultwsdl: https://webservice.exacttarget.com/etframework.wsdl
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
authenticationurl: https://auth.exacttargetapis.com/v1/requestToken?legacy=1
wsdl_file_local_loc: /tmp/ExactTargetWSDL.s6.xml

0 comments on commit 8601135

Please sign in to comment.