2017-02-14 72 views
2

我想使用Python Zeep SOAP客户端向思科CUCM发出SOAP调用。 在Cisco WSDL文件是服务definded:在Python中更改服务URL Zeep

<service name="AXLAPIService"> 
    <port binding="s0:AXLAPIBinding" name="AXLPort"> 
     <soap:address location="https://CCMSERVERNAME:8443/axl/"/> 
    </port> 
</service> 

现在我想改变“CCMSERVERNAME”,以真实的东西,如“192.168.250.10”不改变WSDL。

但从文档我找不到任何改变。

我在这里发现了一个关于使用“Client.set_address()”更改URL的讨论,但这不再起作用。

有人可以给我一个提示吗?

编辑: 随着MVT的帮助下,我得到了它,对于同样的问题任何人,请用这个命令的服务:

service = client.create_service(" {http://www.cisco.com/AXLAPIService/}AXLAPIBinding","https://192.168.250.10:8443/axl/") 

这里从一个工作SOAP调用一个例子:

phones = service.listPhone({'devicePoolName':'Default'},returnedTags={'name':'','model':''}) 

返回列表中的设备:

SEPFFFFFFFFFFAA Cisco 7841 
SEPAAAABBBB2222 Cisco 7841 

回答

0

对于内部服务器上的端点,在互联网上不可达,端口转发端口80使用SSH为localhost:8080我做了下面的代码片段,它拷贝服务绑定并将转换应用于绑定地址以创建新服务。

def get_service(client, translation) 
    if translation: 
     service_binding = client.service._binding.name 
     service_address = client.service._binding_options['address'] 
     return client.create_service(
      service_binding, 
      service_address.replace(*translation, 1) 
    else: 
     return client.service 

# ssh port forwarded internal.example.com:80 to localhost:8080 

client = zeep.Client(wsdl="localhost:8080/endpoint?WSDL") 

# client.service now points to the unreachable url internal.example.com/endpoint 

service = get_service(client=client, translation=('internal.example.com', 'localhost:8080')) 

# service now points to localhost:8080/endpoint