Ruby on rails 如何使用rails 4中的SAVON 2在SOAP中调用数组
通过soapui请求Ruby on rails 如何使用rails 4中的SAVON 2在SOAP中调用数组,ruby-on-rails,web-services,api,soap,savon,Ruby On Rails,Web Services,Api,Soap,Savon,通过soapui请求 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <soapenv:Header/> <soapenv:Body>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:GetLastDayRounds>
<!--Optional:-->
<tem:glIds>
<!--Zero or more repetitions:-->
<arr:int>7910</arr:int>
<arr:int>791524</arr:int>
<arr:int>5613</arr:int>
</tem:glIds>
</tem:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetLastDayRoundsResponse xmlns="http://tempuri.org/">
<GetLastDayRoundsResult xmlns:a="http://schemas.datacontract.org/GL.WS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Message i:nil="true"/>
<a:Rounds xmlns:b="http://schemas.datacontract.org/GL.WS.Entities">
<b:Round>
<b:AdjustedScore>91</b:AdjustedScore>
</b:Round>
<b:Round>
<b:AdjustedScore>92</b:AdjustedScore>
</b:Round>
<b:Round>
<b:AdjustedScore>191</b:AdjustedScore>
</b:Round>
</a:Rounds>
<a:Status>Success</a:Status>
</GetLastDayRoundsResult>
</GetLastDayRoundsResponse>
</s:Body>
</s:Envelope>
现在我想我的SAVON 2电话应该是这样的:
response = @client.call(:get_last_day_rounds, message: {"tns:glIds" => [7910,791524]})
response = @client.call(:get_last_day_rounds, message: { "tns:glIds" => { "int" => [79124,123] } } )
但是我从供应商那里得到了内部错误。如果我通过SOAPUI测试这个,我会得到结果,而且一切都很好,但是我不知道如何通过Savon2进行测试
谢谢
SAVON 2日志:
应要求:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetLastDayRounds>
<tns:glIds>7910</tns:glIds>
<tns:glIds>791524</tns:glIds>
</tns:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
SAVON日志:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetLastDayRounds>
<tns:glIds>
<int>791524</int>
<int>123</int>
</tns:glIds>
</tns:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
791524
123
我发现了以下错误
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-AU">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
a:内部故障
由于内部错误,服务器无法处理该请求。有关错误的详细信息,请在服务器上启用IncludeExceptionDetailInFaults(从ServiceBehaviorAttribute或从serviceDebug配置行为),以便将异常信息发送回客户端,或者根据Microsoft.NET Framework SDK文档打开跟踪,并检查服务器跟踪日志。
好的,我找到了。(以防有人使用)
名称空间需要更改
因此,电话将是:
def make_connection
url = "http://api.wsdl.link"
@client = Savon.client(
wsdl: url,
namespaces: {
"xmlns:tem" => "http://tempuri.org/",
"xmlns:arr" => "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
},
env_namespace: :soapenv,
log: true, # set true to switch on logging
log_level: :debug,
pretty_print_xml: true,
open_timeout: 3000000,
read_timeout: 3000000
)
end
现在当我打电话时:
response = @client.call(:get_last_day_rounds, message: {"tns:glIds" => { "arr:int" => [5613,79810] } })
我得到了结果
干杯您应该提供日志的输出。给您,伙计。我添加了日志。
def make_connection
url = "http://api.wsdl.link"
@client = Savon.client(
wsdl: url,
namespaces: {
"xmlns:tem" => "http://tempuri.org/",
"xmlns:arr" => "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
},
env_namespace: :soapenv,
log: true, # set true to switch on logging
log_level: :debug,
pretty_print_xml: true,
open_timeout: 3000000,
read_timeout: 3000000
)
end
response = @client.call(:get_last_day_rounds, message: {"tns:glIds" => { "arr:int" => [5613,79810] } })