简体   繁体   English

python suds或sf-suds如何与“ wsdl:import”一起使用?

[英]How python suds or sf-suds work with “wsdl:import”?

For example, i have wsdl in wsdl_url : 例如,我在wsdl_url有wsdl:

<wsdl:definitions ...>
   <wsdl:import namespace="wsdl/auth/v1/" location="wsdl/auth/v1/soap/auth.wsdl"/>
   <wsdl:import namespace="wsdl/core/v1/" location="wsdl/v1/soap/core.wsdl"/>
   ...
</wsdl>

How to call a method from namespace="wsdl/auth/v1/" ? 如何从namespace="wsdl/auth/v1/"调用方法? auth.wsdl contain method login. auth.wsdl包含方法登录。

import suds
client = suds.client.Client(wsdl_url)
client.service.login(...)

I could not find a service with both namespace to test, but the logic seems to apply here. 我找不到同时测试两个名称空间的服务,但逻辑似乎适用于此。

After creating the client, print it. 创建客户端后,打印它。 You will have something like below: 您将看到以下内容:

url = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl"
client = suds.client.Client(url)
print client

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913

Service ( Weather ) tns="http://ws.cdyne.com/WeatherWS/"
   Prefixes (1)
      ns0 = "http://ws.cdyne.com/WeatherWS/"
   Ports (2):
      (WeatherSoap)
         Methods (3):
            GetCityForecastByZIP(xs:string ZIP, )
            GetCityWeatherByZIP(xs:string ZIP, )
            GetWeatherInformation()
         Types (8):
            ....
      (WeatherSoap12)
         Methods (3):
            GetCityForecastByZIP(xs:string ZIP, )
            GetCityWeatherByZIP(xs:string ZIP, )
            GetWeatherInformation()
         Types (8):
            ....

Then you can set wich service you want with client.set_options(service='service1', port='port1') . 然后,可以使用client.set_options(service='service1', port='port1') After that, just call service.function. 之后,只需调用service.function。 In the example: 在示例中:

client.set_options(port='WeatherSoap12')
client.service.GetWeatherInformation()

more info: https://fedorahosted.org/suds/wiki/Documentation 更多信息: https : //fedorahosted.org/suds/wiki/Documentation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM