ruby - Savon 请求失败

标签 ruby savon

我正在使用 savon 0.9.7 和 ruby​​ 1.8.7,我提出以下要求:

client = Savon::Client.new do
  wsdl.document = "http://localhost:3000/wsdl/service.asmx?WSDL"
end

response = client.request "Body3DGeneration" do
  soap.body = {
    :path => 'adsa',
    :measures => 'assaasd',
    :landmarks => 'adsd'
  }
  http.headers["SOAPAction"] = "http://xx.xx.xx.xx/services/1"
end

Savon 发送此 POST:

SOAPAction: http://xx.xx.xx.xx/services/1, 
Content-Type: text/xml;charset=UTF-8, 
Content-Length: 526

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="http://xx.xx.xx.xx/services" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="http://xx.xx.xx.xx/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <ins0:Body3DGeneration>
      <ins0:path>adsa</ins0:path>
      <ins0:measures>assaasd</ins0:measures>
      <ins0:landmarks>adsd</ins0:landmarks>
    </ins0:Body3DGeneration>
  </env:Body>
</env:Envelope>

但是服务器需要这样的东西:

Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://xx.xx.xx.xx/services/1"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Body3DGeneration xmlns="http://xx.xx.xx.xx/services">
      <path>string</path>
      <landmarks>string</landmarks>
      <measures>string</measures>
    </Body3DGeneration>
  </soap:Body>
</soap:Envelope>

我遇到下一个错误:

SOAP response (status 500):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Server was unable to process request. ---&gt; Data at the root level is invalid. Line 1, position 1.</faultstring>
      <detail />
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

Savon::SOAP::Fault: (soap:Server) Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1.

你能帮帮我吗?我认为我没有做好 savon 请求,但我在文档中找不到任何内容。

最佳答案

您可以使用原始查询示例检查服务器

  response = client.request do |soap| 
      soap.xml = '<?xml version="1.0" encoding="UTF-8"?>....'
      http.headers["SOAPAction"] = "http://xx.xx.xx.xx/services/1"
   end

关于ruby - Savon 请求失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7684725/

相关文章:

ruby-on-rails - Ruby/RoR - 计算数组中元素的出现次数

ruby - 如何让 has_secure_password 在生产中工作?

ruby-on-rails - 无法找到 SOAP 操作 RAILS + SAVON

Ruby Savon Gem 更改日志记录配置

ruby-on-rails - 使用 Netsuite Ruby Gem 获取事务时出错 - Savon::SOAPFault: (soapenv:Server.userException)

ruby - 使用 Magento SOAP API v1 和 Savon Ruby Gem v2 创建类别时获取 'Error cannot find parameter'

Java 与 Ruby 的 SOAP 处理

sql - rails union hack,如何将两个不同的查询放在一起

ruby - 重构前置条件和后置条件

ruby-on-rails - 如何在 Rails 中将数组对象转换为散列