Ruby Savon 绑定问题

发布于 2024-12-11 02:59:30 字数 1007 浏览 0 评论 0原文

我正在使用 Savon 来使用 Web 服务,并且 WSDL 带有 2 个绑定。如何指定在 Savon 中使用哪个绑定?其中之一是 http,另一个是 https。 我正在尝试使用 https 服务。

有关 wsdl 的信息

<wsdl:service name="ExampleService">
  <wsdl:port name="ES" binding="tns:ES">
    <soap:address location="http://example.com/service.svc"/>
  </wsdl:port>
  <wsdl:port name="ES1" binding="tns:ES1">
    <soap:address location="https://example.com/service.svc"/>
  </wsdl:port>
</wsdl:service>

我如何使用 ES1?我现在使用 savon 的代码是

require 'savon'
require 'httpclient'
wsdl = "https://example.com/Messages.wsdl"
driver = Savon::Client.new(wsdl)
response = driver.request "someAction"

当我使用soap4r时,我可以使用以下代码选择绑定:

require 'httpclient'
require 'soap/wsdlDriver'
wsdl = "https://example.com/Messages.wsdl"
soap_client = SOAP::WSDLDriverFactory.new(wsdl)
driver = soap_client.create_rpc_driver('ExampleService','ES1')

I am consuming webservices with Savon and the WSDL comes with 2 bindings. How do I specify which binding to use in Savon? One of them is http and the other one is https. I am trying to use the https service.

The information on wsdl

<wsdl:service name="ExampleService">
  <wsdl:port name="ES" binding="tns:ES">
    <soap:address location="http://example.com/service.svc"/>
  </wsdl:port>
  <wsdl:port name="ES1" binding="tns:ES1">
    <soap:address location="https://example.com/service.svc"/>
  </wsdl:port>
</wsdl:service>

How do i use ES1? The code I am using now with savon is

require 'savon'
require 'httpclient'
wsdl = "https://example.com/Messages.wsdl"
driver = Savon::Client.new(wsdl)
response = driver.request "someAction"

When I am using soap4r, I can choose the binding using the following code:

require 'httpclient'
require 'soap/wsdlDriver'
wsdl = "https://example.com/Messages.wsdl"
soap_client = SOAP::WSDLDriverFactory.new(wsdl)
driver = soap_client.create_rpc_driver('ExampleService','ES1')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天 2024-12-18 02:59:30

创建 Savon::Client 实例时,您应该能够覆盖端点:

client = Savon::Client.new do
  wsdl.document = "https://example.com/Messages.wsdl"
  wsdl.endpoint = "https://example.com/service.svc"
end

response = client.request "someAction"

You should be able to overwrite the endpoint when creating a Savon::Client instance:

client = Savon::Client.new do
  wsdl.document = "https://example.com/Messages.wsdl"
  wsdl.endpoint = "https://example.com/service.svc"
end

response = client.request "someAction"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文