首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Savon请求失败

Savon请求失败
EN

Stack Overflow用户
提问于 2011-10-07 16:27:54
回答 1查看 2.2K关注 0票数 2

我使用的是savon 0.9.7和ruby 1.8.7,我提出这个请求:

代码语言:javascript
复制
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发送这篇文章:

代码语言:javascript
复制
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>

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

代码语言:javascript
复制
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>

我得到了下一个错误:

代码语言:javascript
复制
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请求,但我在文档中找不到任何东西。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-07 18:24:14

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

代码语言:javascript
复制
  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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7684725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档