Home > Uncategorized > Consuming a .NET webservice with #python

Consuming a .NET webservice with #python

soap__largeTo consume a .NET SOAP ASMX webservice from Pyhon, you need to use a proxy class, which you can generate using Suds and a tool called wsdl2soaplib by fvieira .

You have to install Suds using

sudo python setup.py install

then generate the proxy class using

./wsdl2soaplib.py http://www.regcheck.org.uk/api/reg.asmx?wsdl > regcheck.py

And it generates a class such as

“””SOAP web services generated from:
http://www.regcheck.org.uk/api/reg.asmx?wsdl.
“””

from soaplib.core.model.primitive import (
Any, AnyAsDict, AnyUri, Boolean, Date, DateTime,
Decimal, Double, Duration, Integer, Float, Mandatory, String
)
from soaplib.core.model.clazz import Array, ClassModel

from soaplib.core.model.base import Null

from soaplib.core.service import soap, DefinitionBase
from soaplib.core.model.enum import Enum
class ArrayOfString(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfString“
“””
string = Array(String)
class ArrayOfArrayOfString(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfArrayOfString“
“””
ArrayOfString = Array(ArrayOfString)
class DataGrid(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}DataGrid“
“””
json = String
columnNames = ArrayOfString
data = ArrayOfArrayOfString
class UKTest(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}UKTest“
“””
TestDate = String
ExpiryDate = String
Result = String
Odometer = String
TestNumber = String
FailureReasons = ArrayOfString
class ArrayOfUKTest(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}ArrayOfUKTest“
“””
UKTest = Array(UKTest)
class UKMOTData(ClassModel):
“””SOAP complex type “{http://regcheck.org.uk}UKMOTData“
“””
Tests = ArrayOfUKTest
taxDate = String
Json = String
ExtendedInformation = ArrayOfArrayOfString
ExtendedInformationJson = String
class CarReg(DefinitionBase):
“””SOAP service “CarReg“ with target namespace http://regcheck.org.uk.
“””

@soap(String, String, Integer, _returns=CarSpecificationsResponse)
def CarSpecifications(self, make, model, year):
“””Parameters:

“make“ — string (optional)
“model“ — string (optional)
“year“ — int

Returns: CarSpecificationsResponse
“””
return None
@soap(String, String, _returns=CheckResponse)
def Check(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckResponse
“””
return None
@soap(String, String, String, _returns=CheckAustraliaResponse)
def CheckAustralia(self, RegistrationNumber, State, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“State“ — string (optional)
“username“ — string (optional)

Returns: CheckAustraliaResponse
“””
return None
@soap(String, String, _returns=CheckDenmarkResponse)
def CheckDenmark(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckDenmarkResponse
“””
return None
@soap(String, String, _returns=CheckFinlandResponse)
def CheckFinland(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckFinlandResponse
“””
return None
@soap(String, String, _returns=CheckFranceResponse)
def CheckFrance(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckFranceResponse
“””
return None
@soap(String, String, _returns=CheckIrelandResponse)
def CheckIreland(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckIrelandResponse
“””
return None
@soap(String, String, _returns=CheckItalyResponse)
def CheckItaly(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckItalyResponse
“””
return None
@soap(String, String, _returns=CheckNetherlandsResponse)
def CheckNetherlands(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNetherlandsResponse
“””
return None
@soap(String, String, _returns=CheckNewZealandResponse)
def CheckNewZealand(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNewZealandResponse
“””
return None
@soap(String, String, _returns=CheckNorwayResponse)
def CheckNorway(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckNorwayResponse
“””
return None
@soap(String, String, _returns=CheckPortugalResponse)
def CheckPortugal(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckPortugalResponse
“””
return None
@soap(String, String, _returns=CheckSpainResponse)
def CheckSpain(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckSpainResponse
“””
return None
@soap(String, String, _returns=CheckSwedenResponse)
def CheckSweden(self, RegistrationNumber, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“username“ — string (optional)

Returns: CheckSwedenResponse
“””
return None
@soap(String, String, String, _returns=CheckUSAResponse)
def CheckUSA(self, RegistrationNumber, State, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“State“ — string (optional)
“username“ — string (optional)

Returns: CheckUSAResponse
“””
return None
@soap(String, String, String, _returns=UKMOTResponse)
def UKMOT(self, RegistrationNumber, Model, username):
“””Parameters:

“RegistrationNumber“ — string (optional)
“Model“ — string (optional)
“username“ — string (optional)

Returns: UKMOTResponse
“””
return None

WSDL_TYPES = {
‘ArrayOfArrayOfString’: ArrayOfArrayOfString,
‘ArrayOfString’: ArrayOfString,
‘ArrayOfUKTest’: ArrayOfUKTest,
‘DataGrid’: DataGrid,
‘UKMOTData’: UKMOTData,
‘UKTest’: UKTest,
‘Vehicle’: Vehicle
}

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: