Ruby on rails:发送xml消息时出错

时间:2016-03-04 15:39:16

标签: ruby-on-rails xml

我尝试将xml文件发送到Web服务,但它无法正常工作。网络服务供应商不知道。

如果您阅读了错误消息,看起来使用了错误的soap版本,但供应商尝试使用相同的xml文件,并且他对此文件没有任何问题。我不知道出了什么问题。

代码:

#Declaration
host     = "bar.foo.nl";
path     = "/services/setu.asmx";
port     = 443;
username = "xxx"
password = "yyy";
ssl      = true; 

#Create connection
req = Net::HTTP::Post.new(path)
req.basic_auth(username, password)

http = Net::HTTP.new(host, port)
http.use_ssl = ssl


#send file
res = http.request(req, 'D:/test.xml')

#show result
puts res.code
puts res.body

编辑:xml文件:XML FILE

错误(500码):

  

可能的SOAP版本不匹配:Envelope命名空间   http://ns.hr-xml.org/2007-04-15出人意料。期待   http://schemas.xmlsoap.org/soap/envelope/

1 个答案:

答案 0 :(得分:0)

我在您上传的文件中没有看到任何肥皂声明,看起来您正在联系的服务需要它。

http://www.w3schools.com/xml/xml_soap.asp开始,然后将您的内容修改为包装在肥皂信封中。