从WSDL文件创建zope.interface风格的接口
项目描述
wsdl2interface
本包提供了一个简单的脚本,可以从WSDL文件生成zope.interface风格接口的代码。它依赖于suds进行转换。
安装
要安装此包,请使用easy_install,buildout或其他机制安装Python eggs,例如。
$ easy_install -U wsdl2interface
您也可以将其作为另一个包的依赖项安装,例如,通过在该包的setup.py install_requires行中列出它。
使用方法
默认情况下,wsdl2interface会安装同名的控制台脚本,您可以使用它将生成的代码打印到屏幕上。将WSDL文件的URL(可以是本地文件的file:// URL)作为唯一参数传递
$ wsdl2interface http://www.xignite.com/xIndexComponents.asmx?WSDL
输出将类似于以下内容
"""SOAP web services generated from: http://www.xignite.com/xIndexComponents.asmx?WSDL. """ from zope.interface import Interface, Attribute from zope import schema class IArrayOfComponent(Interface): """SOAP complex type ``{http://www.xignite.com/services/}ArrayOfComponent`` """ Component = Attribute('Type: IComponent[]. Required: False') class IArrayOfPricedComponent(Interface): """SOAP complex type ``{http://www.xignite.com/services/}ArrayOfPricedComponent`` """ PricedComponent = Attribute('Type: IPricedComponent[]. Required: False') class ICommon(Interface): """SOAP complex type ``{http://www.xignite.com/services/}Common`` """ Outcome = Attribute('Type: IOutcomeTypes. Required: True') Message = schema.TextLine(description=u"WSDL type: string", required=False) Identity = schema.TextLine(description=u"WSDL type: string", required=False) Delay = schema.Float(description=u"WSDL type: double", required=True) class IComponent(Interface): """SOAP complex type ``{http://www.xignite.com/services/}Component`` """ Security = Attribute('Type: ISecurity. Required: False') Weight = schema.Float(description=u"WSDL type: double", required=True) AdjustmentFactor = schema.Float(description=u"WSDL type: double", required=True) IndexComponentWeightType = Attribute('Type: IIndexComponentWeightTypes. Required: True') class IComponents(Interface): """SOAP complex type ``{http://www.xignite.com/services/}Components`` """ Outcome = Attribute('Type: IOutcomeTypes. Required: True') Message = schema.TextLine(description=u"WSDL type: string", required=False) Identity = schema.TextLine(description=u"WSDL type: string", required=False) Delay = schema.Float(description=u"WSDL type: double", required=True) Security = Attribute('Type: ISecurity. Required: False') Count = schema.Int(description=u"WSDL type: int", required=True) Components = Attribute('Type: IArrayOfComponent. Required: False') class IHeader(Interface): """SOAP complex type ``{http://www.xignite.com/services/}Header`` """ Username = schema.TextLine(description=u"WSDL type: string", required=False) Password = schema.TextLine(description=u"WSDL type: string", required=False) Tracer = schema.TextLine(description=u"WSDL type: string", required=False) class IIdentifierTypes(Interface): """SOAP enumeration ``{http://www.xignite.com/services/}IdentifierTypes`` """ Symbol = Attribute('Enumeration value') CIK = Attribute('Enumeration value') CUSIP = Attribute('Enumeration value') ISIN = Attribute('Enumeration value') Valoren = Attribute('Enumeration value') SEDOL = Attribute('Enumeration value') class IIndexComponentWeightTypes(Interface): """SOAP enumeration ``{http://www.xignite.com/services/}IndexComponentWeightTypes`` """ Unknown = Attribute('Enumeration value') MarketCapitalizationWeighted = Attribute('Enumeration value') EqualWeighted = Attribute('Enumeration value') PriceWeighted = Attribute('Enumeration value') MarketCapitalizationWeightedWithLimits = Attribute('Enumeration value') OtherWeighting = Attribute('Enumeration value') class IOutcomeTypes(Interface): """SOAP enumeration ``{http://www.xignite.com/services/}OutcomeTypes`` """ Success = Attribute('Enumeration value') SystemError = Attribute('Enumeration value') RequestError = Attribute('Enumeration value') RegistrationError = Attribute('Enumeration value') class IPricedComponent(Interface): """SOAP complex type ``{http://www.xignite.com/services/}PricedComponent`` """ Outcome = Attribute('Type: IOutcomeTypes. Required: True') Message = schema.TextLine(description=u"WSDL type: string", required=False) Identity = schema.TextLine(description=u"WSDL type: string", required=False) Delay = schema.Float(description=u"WSDL type: double", required=True) Symbol = schema.TextLine(description=u"WSDL type: string", required=False) Name = schema.TextLine(description=u"WSDL type: string", required=False) Exchange = schema.TextLine(description=u"WSDL type: string", required=False) CIK = schema.TextLine(description=u"WSDL type: string", required=False) Cusip = schema.TextLine(description=u"WSDL type: string", required=False) ISIN = schema.TextLine(description=u"WSDL type: string", required=False) SEDOL = schema.TextLine(description=u"WSDL type: string", required=False) Valoren = schema.TextLine(description=u"WSDL type: string", required=False) Sector = schema.TextLine(description=u"WSDL type: string", required=False) Class = schema.TextLine(description=u"WSDL type: string", required=False) IndustryGroup = schema.TextLine(description=u"WSDL type: string", required=False) Industry = schema.TextLine(description=u"WSDL type: string", required=False) Country = schema.TextLine(description=u"WSDL type: string", required=False) Currency = schema.TextLine(description=u"WSDL type: string", required=False) Style = schema.TextLine(description=u"WSDL type: string", required=False) Price = schema.Float(description=u"WSDL type: double", required=True) Weight = schema.Float(description=u"WSDL type: double", required=True) Value = schema.Float(description=u"WSDL type: double", required=True) MarketCapitalization = schema.Float(description=u"WSDL type: double", required=True) AdjustmentFactor = schema.Float(description=u"WSDL type: double", required=True) IndexComponentWeightType = Attribute('Type: IIndexComponentWeightTypes. Required: True') class IPricedComponents(Interface): """SOAP complex type ``{http://www.xignite.com/services/}PricedComponents`` """ Outcome = Attribute('Type: IOutcomeTypes. Required: True') Message = schema.TextLine(description=u"WSDL type: string", required=False) Identity = schema.TextLine(description=u"WSDL type: string", required=False) Delay = schema.Float(description=u"WSDL type: double", required=True) Security = Attribute('Type: ISecurity. Required: False') Count = schema.Int(description=u"WSDL type: int", required=True) AsOfDate = schema.TextLine(description=u"WSDL type: string", required=False) Price = schema.Float(description=u"WSDL type: double", required=True) Divisor = schema.Float(description=u"WSDL type: double", required=True) DivisorDate = schema.TextLine(description=u"WSDL type: string", required=False) PricedComponents = Attribute('Type: IArrayOfPricedComponent. Required: False') class ISecurity(Interface): """SOAP complex type ``{http://www.xignite.com/services/}Security`` """ Outcome = Attribute('Type: IOutcomeTypes. Required: True') Message = schema.TextLine(description=u"WSDL type: string", required=False) Identity = schema.TextLine(description=u"WSDL type: string", required=False) Delay = schema.Float(description=u"WSDL type: double", required=True) CIK = schema.TextLine(description=u"WSDL type: string", required=False) Cusip = schema.TextLine(description=u"WSDL type: string", required=False) Symbol = schema.TextLine(description=u"WSDL type: string", required=False) ISIN = schema.TextLine(description=u"WSDL type: string", required=False) Valoren = schema.TextLine(description=u"WSDL type: string", required=False) Name = schema.TextLine(description=u"WSDL type: string", required=False) Market = schema.TextLine(description=u"WSDL type: string", required=False) CategoryOrIndustry = schema.TextLine(description=u"WSDL type: string", required=False) class IXigniteIndexComponents(Interface): """SOAP service ``XigniteIndexComponents`` with target namespace http://www.xignite.com/services/. """ def GetIndexComponents(Identifier, IdentifierType): """Parameters: ``Identifier`` -- string (optional) ``IdentifierType`` -- IIdentifierTypes Returns: GetIndexComponentsResponse """ def GetPricedIndexComponents(Identifier, IdentifierType, AsOfDate): """Parameters: ``Identifier`` -- string (optional) ``IdentifierType`` -- IIdentifierTypes ``AsOfDate`` -- string (optional) Returns: GetPricedIndexComponentsResponse """ def GetPricedIndexComponentsSubset(Identifier, IdentifierType, AsOfDate, StartIndex, EndIndex): """Parameters: ``Identifier`` -- string (optional) ``IdentifierType`` -- IIdentifierTypes ``AsOfDate`` -- string (optional) ``StartIndex`` -- int ``EndIndex`` -- int Returns: GetPricedIndexComponentsSubsetResponse """ WSDL_TYPES = { 'ArrayOfComponent': IArrayOfComponent, 'ArrayOfPricedComponent': IArrayOfPricedComponent, 'Common': ICommon, 'Component': IComponent, 'Components': IComponents, 'Header': IHeader, 'IdentifierTypes': IIdentifierTypes, 'IndexComponentWeightTypes': IIndexComponentWeightTypes, 'OutcomeTypes': IOutcomeTypes, 'PricedComponent': IPricedComponent, 'PricedComponents': IPricedComponents, 'Security': ISecurity }
如果您想从Python中使用生成器,您可以这样做
>>> from suds.client import Client >>> client = Client(wsdlURL) >>> from wsdl2interface import generate >>> generated = generate(client, wsdlURL)
注意事项
本包不保证生成100%正确的代码。在大多数情况下,您可能需要之后进行一些手动清理。它也没有经过充分的测试。欢迎提交补丁!
请注意
WSDL允许Python中无效的标识符。因此,您可能会得到无效Python的属性或方法。脚本将转换空格为下划线,但不会处理名称以数字开头等情况。
具有多个服务定义和/或端口的WSDL文件将被展平。
在WSDL文件中指定的复杂类型和枚举类型将首先作为单个接口输出。
复杂数据类型或枚举生成的接口的docstring中,同时输出命名空间和原始类型名。但是,可能输出相同的名称。
以下命名空间中的类型不输出为复杂数据类型接口,在属性或方法参数中使用时作为基本数据类型引用。
变更日志
1.0b2 - 2010-05-31
对复杂数据类型继承(扩展)的基本支持
1.0b1 - 2010-05-07
指示复杂数据类型中的给定字段是否为必需的(必须设置)。
1.0a5 - 2010-03-22
不要将输入/输出消息类型包含在复杂数据类型的列表中。
如果可能,展开返回类型以显示Suds将返回的实际对象。
1.0a4 - 2010-03-22
根据SOAP输出消息显示每个方法的返回类型。请注意,这并不完美 - 它假设响应类型位于主目标命名空间且无歧义。
1.0a3 - 2010-03-18
在复杂数据类型中,使用zope.schema字段表示常见属性类型。
修改标识符以确保它们是有效的Python标识符。
1.0a2 - 2010-03-17
修复损坏的发布版
1.0a1 - 2010-02-12
初始发布版
项目详情
wsdl2interface-1.0b2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a69bceeca8a69822d79a98b40df63c23dc68bc5646dc4c643f615806e71e44a5 |
|
MD5 | 28513f69c8142b9f3ec6db19b98ab425 |
|
BLAKE2b-256 | f34a9fd2ce78beddc012d5dbfe7341e87b4536826a9cbd48eb3f07afaa726458 |