Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Dynamics CRM with python suds

I want to use microsoft CRM webservice, I tried this code:

wsdl_url = 'http://crm-test:5555/CRMDeveleopment/XRMServices/2011/Organization.svc?wsdl'
username = 'user'
password = 'pass'

from suds.transport.https import WindowsHttpAuthenticated
from suds.client import Client

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)

ntlmTransport = WindowsHttpAuthenticated(username=username, password=password)
metadata_client = Client(wsdl_url, transport=ntlmTransport, cache=None)

and I get this error:

Traceback (most recent call last):
  File "crm.py", line 15, in <module>
    metadata_client = Client(wsdl_url, transport=ntlmTransport)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/usr/lib/python2.7/site-packages/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 157, in __init__
    self.open_imports()
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 202, in open_imports
    imp.load(self)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 314, in load
    d = Definitions(url, options)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 159, in __init__
    self.build_schema()
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 220, in build_schema
    self.schema = container.load(self.options)
  File "/usr/lib/python2.7/site-packages/suds/xsd/schema.py", line 95, in load
    child.dereference()
  File "/usr/lib/python2.7/site-packages/suds/xsd/schema.py", line 323, in dereference
    midx, deps = x.dependencies()
  File "/usr/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 469, in dependencies
    raise TypeNotFound(self.ref)
suds.TypeNotFound: Type not found: '(ManagedPropertyAttributeRequiredLevel, http://schemas.microsoft.com/xrm/2011/Contracts, )'

output for organization

from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated

user = r'domain.net\username'
password = "password"
url = "http://crm-test:5555/XRMServices/2011/Organization.svc?wsdl"


ntlm = WindowsHttpAuthenticated(username = user, password = password)
client = Client(url, transport=ntlm)
print client

error:

$ python organization.py 
DEBUG:suds.transport.http:opening (http://crm-test.kavatelecom.net:5555/XRMServices/2011/Organization.svc?wsdl)
DEBUG:suds.transport.http:opening (http://crm-test.kavatelecom.net:5555/XRMServices/2011/Organization.svc?wsdl=wsdl0)
Traceback (most recent call last):
  File "organization.py", line 15, in <module>
    client = Client(url, transport=ntlm)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/usr/lib/python2.7/site-packages/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 157, in __init__
    self.open_imports()
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 202, in open_imports
    imp.load(self)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 314, in load
    d = Definitions(url, options)
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 159, in __init__
    self.build_schema()
  File "/usr/lib/python2.7/site-packages/suds/wsdl.py", line 220, in build_schema
    self.schema = container.load(self.options)
  File "/usr/lib/python2.7/site-packages/suds/xsd/schema.py", line 95, in load
    child.dereference()
  File "/usr/lib/python2.7/site-packages/suds/xsd/schema.py", line 323, in dereference
    midx, deps = x.dependencies()
  File "/usr/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 469, in dependencies
    raise TypeNotFound(self.ref)
suds.TypeNotFound: Type not found: '(ManagedPropertyAttributeRequiredLevel, http://schemas.microsoft.com/xrm/2011/Contracts, )'
like image 561
nim4n Avatar asked Dec 09 '13 13:12

nim4n


1 Answers

It looks like you are configured to use SOAP 1.2. Can you try your request with Soap 1.1?

I say this because I'm looking at this walk through: http://msdn.microsoft.com/en-us/library/gg594434.aspx

The request mentioned there conforms to the earlier standard (as indicated by the mime type.)

As far as how to do this with the suds library: After reading through the documentation a bit, I was inclined to rip my own eyes out. (Just kidding, I'm just used to reading a different type of documentation I suppose.) I'm sure you're far more used to browsing it than I am, and would be able to figure it out very quickly: http://jortel.fedorapeople.org/suds/doc/

like image 67
Todd Richardson Avatar answered Oct 07 '22 04:10

Todd Richardson