• Max B
  • NEWBIE
  • 0 Points
  • Member since 2004

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
#!/usr/bin/env python
# Copyright (c) 2004 eBridge Software Inc. All rights reserved

from SOAPpy import WSDL
from SOAPpy import structType
from SOAPpy import headerType

# SOAPpy Configuration

#WSDL.Config.debug=1
WSDL.Config.namespaceStyle = '2001'

# For some reason SOAPpy treats SOAP Header as a data on dumping
# and uses "http://www.w3.org/1999/XMLSchema" namespace
# for validation instead of "http://schemas.xmlsoap.org/soap/envelope" namespace
# as you would expect that causes an exception in Types.anyType._validNamespaceURI
WSDL.Config.strictNamespaces = 0

email = "yourname@yourcompany.com"
psw = "yourpassword"
# URL to Partner.wsdl.xml
wsdl = "partner.wsdl"
# Create SOAP Proxy from WSDL
server = WSDL.Proxy(wsdl)

# Assigning sforce namespace to each sfroce method
#
# For some reason WSDLTools does not assign "urn:partner.soap.sforce.com"
# namespace to operations when it parses binding
for method in server.methods.itervalues():
method.namespace = "urn:partner.soap.sforce.com"

# Loggin in sforce using username and password
#
# Parameter names have to be explicitly specified, otherwise
# SOAPBuilder uses fake auto-incremented names
loginResult = server.login(username=email, password=psw)
print "The session id is:", loginResult.sessionId
print "The new server URL is:", loginResult.serverUrl
print "The user id is:", loginResult.userId
print

# Change the binding to a new endpoint
#
# For some reason SOAPpy replaces static soapproxy.proxy endpoint
# with service location for each operation
for method in server.methods.itervalues():
method.location = loginResult.serverUrl

# Assigning returned sessionId to SOAP header
ct = structType(data = {"sessionId" : loginResult.sessionId})
# SOAP Header support in SOAPpy does not allow us to access types declared
# in WSDL, so it has to be done manually
# The idea is from http://sourceforge.net/mailarchive/forum.php?thread_id=4990257&forum_id=1729
"""
#(06/27/05) seems to work fine with SF API 6 and SOAPpy 0.12.0
# Uncomment the double quotted block if you have SOAPpy > 0.12.0

#Ditch the standard namespaces
ct._validURIs = []
#Set the one we want to use
ct._ns = ("ns1", "urn:partner.soap.sforce.com")
"""
hd = headerType(data = {"SessionHeader" : ct})
server.soapproxy.header = hd

# Requesting sforce Server Timestamp
gstr = server.getServerTimestamp()
print "Server's timestamp is:", gstr.timestamp
print

# Requesting sforce user info for the user logged in
ui = server.getUserInfo()
print "User Name:", ui.userFullName
print "User Email:", ui.userEmail
print "User Language:", ui.userLanguage
print "User Locale:", ui.userLocale
print "User Time Zone:", ui.userTimeZone
print "User Default Currency ISO Code:", ui.userDefaultCurrencyIsoCode
print "User Id:", ui.userId
print "Orginization:", ui.organizationName
print "Orginization Id:", ui.organizationId
print "Multi-currency:", ui.organizationMultiCurrency
print "Currency Symbol:", ui.currencySymbol
print

# Listing sforce objects available for the user logged in
dgr = server.describeGlobal()
print "sforce objects available:"
for type in dgr.types:
print type

Message Edited by Max B on 06-27-2005 11:38 AM

  • October 15, 2004
  • Like
  • 1
#!/usr/bin/env python
# Copyright (c) 2004 eBridge Software Inc. All rights reserved

from SOAPpy import WSDL
from SOAPpy import structType
from SOAPpy import headerType

# SOAPpy Configuration

#WSDL.Config.debug=1
WSDL.Config.namespaceStyle = '2001'

# For some reason SOAPpy treats SOAP Header as a data on dumping
# and uses "http://www.w3.org/1999/XMLSchema" namespace
# for validation instead of "http://schemas.xmlsoap.org/soap/envelope" namespace
# as you would expect that causes an exception in Types.anyType._validNamespaceURI
WSDL.Config.strictNamespaces = 0

email = "yourname@yourcompany.com"
psw = "yourpassword"
# URL to Partner.wsdl.xml
wsdl = "partner.wsdl"
# Create SOAP Proxy from WSDL
server = WSDL.Proxy(wsdl)

# Assigning sforce namespace to each sfroce method
#
# For some reason WSDLTools does not assign "urn:partner.soap.sforce.com"
# namespace to operations when it parses binding
for method in server.methods.itervalues():
method.namespace = "urn:partner.soap.sforce.com"

# Loggin in sforce using username and password
#
# Parameter names have to be explicitly specified, otherwise
# SOAPBuilder uses fake auto-incremented names
loginResult = server.login(username=email, password=psw)
print "The session id is:", loginResult.sessionId
print "The new server URL is:", loginResult.serverUrl
print "The user id is:", loginResult.userId
print

# Change the binding to a new endpoint
#
# For some reason SOAPpy replaces static soapproxy.proxy endpoint
# with service location for each operation
for method in server.methods.itervalues():
method.location = loginResult.serverUrl

# Assigning returned sessionId to SOAP header
ct = structType(data = {"sessionId" : loginResult.sessionId})
# SOAP Header support in SOAPpy does not allow us to access types declared
# in WSDL, so it has to be done manually
# The idea is from http://sourceforge.net/mailarchive/forum.php?thread_id=4990257&forum_id=1729
"""
#(06/27/05) seems to work fine with SF API 6 and SOAPpy 0.12.0
# Uncomment the double quotted block if you have SOAPpy > 0.12.0

#Ditch the standard namespaces
ct._validURIs = []
#Set the one we want to use
ct._ns = ("ns1", "urn:partner.soap.sforce.com")
"""
hd = headerType(data = {"SessionHeader" : ct})
server.soapproxy.header = hd

# Requesting sforce Server Timestamp
gstr = server.getServerTimestamp()
print "Server's timestamp is:", gstr.timestamp
print

# Requesting sforce user info for the user logged in
ui = server.getUserInfo()
print "User Name:", ui.userFullName
print "User Email:", ui.userEmail
print "User Language:", ui.userLanguage
print "User Locale:", ui.userLocale
print "User Time Zone:", ui.userTimeZone
print "User Default Currency ISO Code:", ui.userDefaultCurrencyIsoCode
print "User Id:", ui.userId
print "Orginization:", ui.organizationName
print "Orginization Id:", ui.organizationId
print "Multi-currency:", ui.organizationMultiCurrency
print "Currency Symbol:", ui.currencySymbol
print

# Listing sforce objects available for the user logged in
dgr = server.describeGlobal()
print "sforce objects available:"
for type in dgr.types:
print type

Message Edited by Max B on 06-27-2005 11:38 AM

  • October 15, 2004
  • Like
  • 1
I am new to salesforce.com and python. Is anyone able to do integration with slasesforce.com using Python? I am mainly interested in nightly batch job process but any examples or general advice is highly appreciated. One big issue is that we are in a very old version of Python, v2.1.3. I'd like to hear from you and your sucess stories or nightmares if you have done any integration with salesforce.com using python. Thank you very much.

Best Regards

Elaine
  • June 08, 2005
  • Like
  • 0
#!/usr/bin/env python
# Copyright (c) 2004 eBridge Software Inc. All rights reserved

from SOAPpy import WSDL
from SOAPpy import structType
from SOAPpy import headerType

# SOAPpy Configuration

#WSDL.Config.debug=1
WSDL.Config.namespaceStyle = '2001'

# For some reason SOAPpy treats SOAP Header as a data on dumping
# and uses "http://www.w3.org/1999/XMLSchema" namespace
# for validation instead of "http://schemas.xmlsoap.org/soap/envelope" namespace
# as you would expect that causes an exception in Types.anyType._validNamespaceURI
WSDL.Config.strictNamespaces = 0

email = "yourname@yourcompany.com"
psw = "yourpassword"
# URL to Partner.wsdl.xml
wsdl = "partner.wsdl"
# Create SOAP Proxy from WSDL
server = WSDL.Proxy(wsdl)

# Assigning sforce namespace to each sfroce method
#
# For some reason WSDLTools does not assign "urn:partner.soap.sforce.com"
# namespace to operations when it parses binding
for method in server.methods.itervalues():
method.namespace = "urn:partner.soap.sforce.com"

# Loggin in sforce using username and password
#
# Parameter names have to be explicitly specified, otherwise
# SOAPBuilder uses fake auto-incremented names
loginResult = server.login(username=email, password=psw)
print "The session id is:", loginResult.sessionId
print "The new server URL is:", loginResult.serverUrl
print "The user id is:", loginResult.userId
print

# Change the binding to a new endpoint
#
# For some reason SOAPpy replaces static soapproxy.proxy endpoint
# with service location for each operation
for method in server.methods.itervalues():
method.location = loginResult.serverUrl

# Assigning returned sessionId to SOAP header
ct = structType(data = {"sessionId" : loginResult.sessionId})
# SOAP Header support in SOAPpy does not allow us to access types declared
# in WSDL, so it has to be done manually
# The idea is from http://sourceforge.net/mailarchive/forum.php?thread_id=4990257&forum_id=1729
"""
#(06/27/05) seems to work fine with SF API 6 and SOAPpy 0.12.0
# Uncomment the double quotted block if you have SOAPpy > 0.12.0

#Ditch the standard namespaces
ct._validURIs = []
#Set the one we want to use
ct._ns = ("ns1", "urn:partner.soap.sforce.com")
"""
hd = headerType(data = {"SessionHeader" : ct})
server.soapproxy.header = hd

# Requesting sforce Server Timestamp
gstr = server.getServerTimestamp()
print "Server's timestamp is:", gstr.timestamp
print

# Requesting sforce user info for the user logged in
ui = server.getUserInfo()
print "User Name:", ui.userFullName
print "User Email:", ui.userEmail
print "User Language:", ui.userLanguage
print "User Locale:", ui.userLocale
print "User Time Zone:", ui.userTimeZone
print "User Default Currency ISO Code:", ui.userDefaultCurrencyIsoCode
print "User Id:", ui.userId
print "Orginization:", ui.organizationName
print "Orginization Id:", ui.organizationId
print "Multi-currency:", ui.organizationMultiCurrency
print "Currency Symbol:", ui.currencySymbol
print

# Listing sforce objects available for the user logged in
dgr = server.describeGlobal()
print "sforce objects available:"
for type in dgr.types:
print type

Message Edited by Max B on 06-27-2005 11:38 AM

  • October 15, 2004
  • Like
  • 1