Has anyone been able to get the suds soap library to work with the NetSuite WSDL?


Question

Has anyone been able to get the suds soap library to work with the NetSuite WSDL? I get this error when I try to create a client.

from suds.client import Client

#url = 'http://mssoapinterop.org/asmx/simple.asmx?WSDL'
url = 'https://webservices.netsuite.com/wsdl/v2009_2_0/netsuite.wsdl'
client = Client(url)
print client


Traceback (most recent call last):
client = Client(url)
File "build\bdist.win32\egg\suds\client.py", line 112, in __init__
File "build\bdist.win32\egg\suds\reader.py", line 152, in open
File "build\bdist.win32\egg\suds\wsdl.py", line 158, in __init__
File "build\bdist.win32\egg\suds\wsdl.py", line 207, in resolve
File "build\bdist.win32\egg\suds\wsdl.py", line 662, in resolve
File "build\bdist.win32\egg\suds\wsdl.py", line 757, in resolvefaults
Exception: fault 'ExceededRecordCountFault' not defined in portType 'NetSuitePortType'
1
3
2/13/2017 2:51:50 AM

Accepted Answer

https://webservices.netsuite.com/wsdl/v2010_2_0/netsuite.wsdl

I found that it was failing on a validation between this part:

<operation name="checkAsyncStatus">
    <input name="checkAsyncStatusRequest" message="tns:checkAsyncStatusRequest"/>
    <output name="checkAsyncStatusResponse" message="tns:checkAsyncStatusResponse"/>
    <fault name="InvalidSessionFault" message="tns:InvalidSessionFault"/>
    <fault name="InvalidCredentialsFault" message="tns:InvalidCredentialsFault"/>
    <fault name="ExceededRequestLimitFault" message="tns:ExceededRequestLimitFault"/> -- mismatch
    <fault name="UnexpectedErrorFault" message="tns:UnexpectedErrorFault"/>
    <fault name="AsyncFault" message="tns:AsyncFault"/>
</operation>

and this part:

<operation name="checkAsyncStatus">
    <soap:operation soapAction="checkAsyncStatus"/>
    <input name="checkAsyncStatusRequest">
        <soap:header message="tns:headers" part="passport" use="literal"/>
        <soap:header message="tns:headers" part="applicationInfo" use="literal"/>
        <soap:header message="tns:headers" part="partnerInfo" use="literal"/>
        <soap:header message="tns:headers" part="preferences" use="literal"/>
        <soap:body use="literal"/>
    </input>
    <output name="checkAsyncStatusResponse">
        <soap:header message="tns:headers" part="documentInfo" use="literal"/>
        <soap:body use="literal"/>
    </output>
    <fault name="InvalidSessionFault">
        <soap:fault name="InvalidSessionFault" use="literal"/>
    </fault>
    <fault name="InvalidCredentialsFault">
        <soap:fault name="InvalidCredentialsFault" use="literal"/>
    </fault>
    <fault name="ExceededRequestLimitFault">
        <soap:fault name="ExceededRecordCountFault" use="literal"/> -- mismatch
    </fault>
    <fault name="UnexpectedErrorFault">
        <soap:fault name="UnexpectedErrorFault" use="literal"/>
    </fault>
    <fault name="AsyncFault">
        <soap:fault name="AsyncFault" use="literal"/>
    </fault>
</operation>

I changed this:

<fault name="ExceededRequestLimitFault">
    <soap:fault name="ExceededRecordCountFault" use="literal"/>
</fault>

to this:

<fault name="ExceededRequestLimitFault">
    <soap:fault name="ExceededRequestLimitFault" use="literal"/>
</fault>

The modification allows Suds to create the client. Like John mentioned, it does take forever to parse(more than two minutes). I haven't tried using checkAsyncStatus to see if it works.

0
6/4/2011 10:03:06 PM

It is a bit late, but for the record I attach a way of how one can work with NetSuite SuiteTalk SOAP API using Python Zeep.

Example of NetSuite SOAP login with Python and Zeep followed by adding a customer.

# pip3 install zeep
from zeep import Client

WSDL_URL = 'https://webservices.sandbox.netsuite.com/wsdl/v2016_1_0/netsuite.wsdl'
NS_EMAIL = 'admin@example.com'
NS_PASSWORD = '*********'
NS_ROLE = '1111'
NS_ACCOUNT = '1111111'
NS_APPID = 'FFFFFFFF-FFFF-0000-0000-FFFFFFFFFFFF'


def login_client():
    client = Client(WSDL_URL)
    Passport = client.get_type('ns1:Passport')
    AppInfo = client.get_type('ns5:ApplicationInfo')
    passport = Passport(email=NS_EMAIL, password=NS_PASSWORD, account=NS_ACCOUNT)
    app_info = AppInfo(applicationId=NS_APPID)
    login = client.service.login(passport=passport,
                                 _soapheaders={'applicationInfo': app_info})
    print('Login Response: ', login.status)
    return client


# Example usage
client = login_client()

# add a customer
Customer = client.get_type('ns14:Customer')
customer = Customer(
    lastName='Joe',
    firstName='Bloggs',
    email='joe@example.com'
)
response = client.service.add(customer)
print(response)

See also: https://github.com/fmalina/python-netsuite


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon