2014-09-26 32 views
0

例如,我在wsdl_url WSDL:python suds或sf-suds如何与“wsdl:import”一起使用?

<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> 

如何调用从namespace="wsdl/auth/v1/"的方法? auth.wsdl包含方法登录。

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

https://bitbucket.org/jurko/suds/issue/19/add-support-for-importing-xsd-schemas – okuznetsov 2014-09-26 12:23:00

回答

1

我找不到两个名称空间要测试的服务,但逻辑似乎适用于此。

创建客户端后,打印它。你将不得不像下面的东西:

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): 
      .... 

然后你可以设置你想要client.set_options(service='service1', port='port1')至极的服务。之后,只需调用service.function。 在这个例子中:

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

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

相关问题