PyXB Python的XMLSchema绑定包

程序名称:PyXB

授权协议: 未知

操作系统: 跨平台

开发语言: Python

PyXB 介绍

PyXB (“pixbee”) 是一个纯 Python 的类库用来根据 XML Schema 生成对应的 Python
类,开发人员可以使用这些类来操作XML Schema 数据。

示例代码

import weather  
import time  
import pyxb.utils.domutils as domutils  
import sys  
import pyxb.standard.bindings.soapenv as soapenv  
import pyxb.standard.bindings.soapenc as soapenc  
import urllib2

zip = 85711  
if 1 < len(sys.argv):  
    zip = int(sys.argv[1])

# Create an envelope, and give it a body that is the request for the  
# service we want.  
env = soapenv.Envelope()  
env.setBody(weather.GetCityForecastByZIP(ZIP=zip))

# Invoke the service  
uri = urllib2.Request('http://ws.cdyne.com/WeatherWS/Weather.asmx',  
                      env.toxml(),  
                      { 'SOAPAction' : "http://ws.cdyne.com/WeatherWS/GetCityForecastByZIP", 'Content-Type': 'text/xml' } )  
rxml = urllib2.urlopen(uri).read()

# Convert the response to a SOAP envelope, then extract the actual  
# response from the wildcard elements of the body.  Note that because  
# the weather namespace was registered, PyXB already created the  
# binding for the response.  
soap_resp = soapenv.CreateFromDOM(domutils.StringTodoM(rxml))  
resp = soap_resp.Body().wildcardElements()[0]

fc_return = resp.GetCityForecastByZIPResult()  
if fc_return.Success():  
    print 'Got response for %s, %s:' % (fc_return.City(), fc_return.State())  
    for fc in fc_return.forecastresult().Forecast():  
        when = time.strftime('%A, %B %d %Y', fc.Date().timetuple())  
        outlook = fc.Desciption() # typos in WSDL left unchanged  
        low = fc.Temperatures().MorningLow()  
        high = fc.Temperatures().DaytimeHigh()  
        print '  %s: %s, from %s to %s' % (when, outlook, low, high)

PyXB 官网

http://pyxb.sourceforge.net/

相关编程语言

BlazeDS 是一个基于服务器的Java 远程控制(remoting...
OVal 是一个可扩展的Java对象数据验证框架,验证的规...
Volta 是一套开发工具,专为开发分布式、实时系统应...
OpenDDS 是一个开源的 C++ 实现的 对象管理组织 OMG...
JADE (Java Agent DEvelopment Framework) 是一个完...
FastMM ,在D2006和2007中已代替了原来的内存管理器。