【问题标题】:Override WSDL port (i.e., bound URL) in spyne在 spyne 中覆盖 WSDL 端口(即绑定的 URL)
【发布时间】:2013-05-20 21:43:07
【问题描述】:

Spyne 似乎根据服务的访问方式在 WSDL 定义中设置了端口。例如,如果我首先(即重启后)访问http://domain.com/soap-api/ 的服务,它将将该 URL 嵌入到 WSDL 中。但是,如果我使用https://www.domain.com/soap-api/,它将使用该 URL。以下是我的 WSDL 的一部分:

<wsdl:service name="QuestService">
  <wsdl:port name="Application" binding="tns:Application">
    <soap:address location="https://app.stage.domain.com/soap-api/quest/"/>
  </wsdl:port>
</wsdl:service>
<wsdl:portType name="Application">
  <wsdl:operation name="ReceiveLabReqStatus" parameterOrder="ReceiveLabReqStatus">
  ...

当我使用 suds 访问服务器时,suds 似乎并不关心定义中的哪个 URL 以及我提供给 suds 的哪个 URL。但是,其他客户端似乎确实在乎,如果他们没有使用正确的 URL,则会在 URL 不匹配时抛出错误(至少我认为这是正在发生的事情)。

那么,我的问题是:在 Spyne 中有没有办法明确设置与服务关联的 URL?

【问题讨论】:

    标签: python spyne


    【解决方案1】:

    是的,这对于 2.10.7 及更高版本是可能的。我已经修复了与该用例相关的错误并更新了文档。假设您使用的是 WsgiApplication 系列传输,以下是操作方法:

    wsgi_app = WsgiApplication(...)
    wsgi_app.doc.wsdl11.build_interface_document("http://example.com")
    

    请注意,TwistedWebResource 传输方式略有不同:

    resource = TwistedWebResource(...)
    resource.http_transport.doc.wsdl11.build_interface_document("http://example.com")
    

    文档相关部分的链接是:

    http://spyne.io/docs/2.10/reference/server.html#module-spyne.server.wsgi http://spyne.io/docs/2.10/reference/server.html#module-spyne.server.twisted

    让我知道你的效果如何。

    【讨论】:

    • 谢谢布拉克!像魅力一样工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2016-04-05
    • 1970-01-01
    相关资源
    最近更新 更多