我嘗試將xml文件發送到Web服務,但它不起作用。 Web服務供應商不知道。Ruby on rails:發送xml消息時出錯
如果您閱讀錯誤消息,它看起來像使用了錯誤的肥皂版本,但供應商嘗試使用相同的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碼):
Possible SOAP version mismatch: Envelope namespace http://ns.hr-xml.org/2007-04-15 was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/ .
在您的文件中是否存在soap命名空間定義? – Matt
是的,我上傳了xml文件。 – Dave