如何在wsdl文件的soap请求中添加context.envlope?(Python,suds)

时间:2016-08-09 10:09:56

标签: python web-services soap wsdl suds

我想将targetnamespace添加到xml架构中的元素。

我使用suds作为肥皂客户。

例如。元素为<ns0:RateRequest>,我希望它为<ns0:RateRequest xmlns:ns0="http://fedex.com/ws/rate/v18">

我厌倦了使用正则表达式,但我没有得到结果。

class Filter(MessagePlugin):
    def received(self, context):
        context.envelope= re.sub(r'<ns0:RateRequest>',
            '<ns0:RateRequest xmlns:ns0="http://fedex.com/ws/rate/v18">', 
            context.envelope)

还有这个

class Filter(MessagePlugin):
    def received(self, context):
        reply= context.reply
        context.reply= reply[reply.find("<ns0:RateRequest"):reply.rfind(' xmlns:ns0="http://fedex.com/ws/rate/v18">')+1]

我使用received sending marshalled

尝试了上述def

我用这样的方式叫它

client= Client(url, plugins=[Filter()])

我正在为FedEx集成做这个,我收到一个错误,我发布了here,这样做我认为我可以解决这个问题。

0 个答案:

没有答案