加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 带有自定义绑定的Savon

发布时间:2020-12-16 21:06:42 所属栏目:百科 来源:网络整理
导读:我有一个很好的任务,就是使用带有Rails的大量SOAP api. SOAP服务有三种不同的绑定; wsHttpBinding,wsHttpBinding与x509,以及自定义绑定.我只能使用wsHttpBinding来击中两个端点,但是第三个端点需要用户名和密码,这与之无关.我因为证书而避免使用x509,并且自
我有一个很好的任务,就是使用带有Rails的大量SOAP api. SOAP服务有三种不同的绑定; wsHttpBinding,wsHttpBinding与x509,以及自定义绑定.我只能使用wsHttpBinding来击中两个端点,但是第三个端点需要用户名和密码,这与之无关.我因为证书而避免使用x509,并且自定义绑定在SoapUI中运行良好,但是使用Savon我得到以下错误.

The message with Action ” cannot be processed at the receiver,due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements,e.g. Message,Transport,None).

我已经使用了Savon生成的确切XML并将其放入SoapUI并且它可以工作.

这是一个具有约束力的问题吗?有没有办法告诉它使用这个自定义绑定?

这是我在App.config中找到的自定义绑定

<bindings>
  <customBinding>
    <binding name="cust">
        <textMessageEncoding messageVersion="Soap12" />
        <httpTransport />
    </binding>
    <binding name="cust1">
        <textMessageEncoding messageVersion="Soap12" />
        <httpTransport />
    </binding>
    <binding name="cust2">
        <textMessageEncoding messageVersion="Soap12" />
        <httpTransport />
    </binding>
  </customBinding>
</bindings>
<endpoint address="http://api.xyz.com/stuff.svc/cust"
    binding="customBinding" bindingConfiguration="cust" contract="stuff.Xstuff"
    name="cust" />

编辑#1

这是我当前的客户端设置,这有助于它.

@client = Savon.client(
      wsdl: 'http://api.xyz.com/stuff.svc?wsdl',wsse_auth: %w'username password',wsse_timestamp: true,raise_errors: false,log: true,log_level: :debug,soap_version: 2,pretty_print_xml: true,convert_request_keys_to: :none,use_wsa_headers: true,headers: {'Content-Type' => 'application/soap+xml; charset=utf-8'}

编辑#2

我发现了这个问题. Savon没有像SoapUI那样在Content-Type中设置动作.感谢@RicardoPontual建议再次尝试比较Savon和SoapUI请求,这让我更仔细地看一下并注意到这个问题.

headers: {'Content-Type' => 'application/soap+xml;charset=UTF-8;action="tempuri.org/stuf??f/set_table_stuff"'}

解决方法

基于我们在评论中讨论的内容,添加标题以及您想要使用的操作的操作可以解决问题,如下所示:
@client = Savon.client(
      wsdl: 'http://api.xyz.com/stuff.svc?wsdl',headers: {'Content-Type' => 'application/soap+xml;charset=UTF-8;action="tempuri.org/stuf??f/set_table_stuff"'}
      );

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读