使用SAVON的Ruby SOAP客户端无法工作,而PHP SOAP客户端可以正常工作。

3

你好,我正在测试几个Web服务,并尝试使用SAVON和我的WSDL编写客户端。我有一个名为log_process的可用操作,但是在尝试访问时出现错误。我已经在PHP中编写了类似的脚本,它可以正常工作。我已经尝试过

require 'net/http'
require "uri"
require 'savon' 

client = Savon.client(wsdl: "http://somedomain.com/projects/shared/abc.wsdl")

@a=client.operations

puts @a
    
ary={0 =>"art", 1 =>"bac", 2 =>"arr"}
   
@result = client.call(:log_process, message:{0 =>"asdf", 1 =>"qwer", 2 =>"arr"})
puts @result

我得到了以下错误:

raise_soap_and_http_errors!': (SOAP-ENV:Client) Bad Request (Savon::SOAPFault)

我的php解决方案如下:

$result = $client->log_process(array(0=>$user_name,1=>$user_pwd,2=>$display_type));

你有没有想过Ruby中的等效方法是什么?或者我是否以正确的方式调用了操作?


为什么要在operations()的结果上调用log_process?我猜你想要的是client.log_process - Mark Thomas
尝试过这个方法,也尝试了 @result = client.call(:log_process, message:{0 =>"asdf", 1 =>"asg", 2 =>"arr"})。 - Arihant Godha
更新了问题,现在我收到了上述错误,提示raise_soap_and_http_errors!': (SOAP-ENV:Client) Bad Request (Savon::SOAPFault)。 - Arihant Godha
2个回答

2

我知道这可能有点晚,但是我遇到了同样的问题,想要使用Savon设置SOAP请求到一个我之前用PHP Soap服务器处理过的SOAP服务器。我找到了另一篇相关的帖子,似乎添加message_tag选项可以解决问题。

这是因为在我的情况下,WSDL期望在XML中看到functionNameRequest,但是Savon只发送了funcionName。通过将message_tag设置为functionNameRequest,SOAP服务器能够正确地映射所请求的函数。

这是帮助我的线程:https://github.com/savonrb/savon/issues/520 下面引用了相关代码:

嗨, 我只是分享一下,以防有用。

我正在使用Savon 2.3.0,我猜测这个宝石有一些问题,无法自动从我的WSDL中识别参数。我对SOAP一无所知,这是我第一次实际使用它。

我正在处理TradeTracker的WSDL

使用以下代码,我让它工作了:

client = Savon.client do
  wsdl "http://ws.tradetracker.com/soap/affiliate?wsdl"
  namespace_identifier :ns1
end

credentials = {
  customerID: 123123,
  passphrase: "123123123"
}

response = client.call(:authenticate, message_tag: :authenticate, message: credentials)

1

尝试:

@result = client.call(:log_process, message:["asdf", "asg", "arr"]) 

在PHP代码中,您只发送了一个参数,它是一个数组。

我也尝试了这个,得到了以下错误:`raise_soap_and_http_errors!': (SOAP-ENV:Server) Procedure 'string' not present (Savon::SOAPFault)。 - Arihant Godha

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接