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

时间:2021-07-28 07:34:40

I try to send a xml file to a web service, but it's not working. The web service supplier has no idea.

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

If you read the error message, it looks like there is a wrong soap version used, but the supplier tried it with the same xml file and he had no problems with this file. I have no idea what's wrong.

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

The code:

#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

EDIT: The xml file: XML FILE

编辑:xml文件:XML文件

The error (500 code):

错误(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版本不匹配:Envelope命名空间http://ns.hr-xml.org/2007-04-15是意外的。期待http://schemas.xmlsoap.org/soap/envelope/。

1 个解决方案

#1


0  

I don't see any soap declarations in the file you've uploaded, and it looks like the service you're contacting requires it.

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

Start with http://www.w3schools.com/xml/xml_soap.asp and rework your content to be wrapped in a soap envelope.

从http://www.w3schools.com/xml/xml_soap.asp开始,将您的内容重新整理成肥皂信封。

#1


0  

I don't see any soap declarations in the file you've uploaded, and it looks like the service you're contacting requires it.

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

Start with http://www.w3schools.com/xml/xml_soap.asp and rework your content to be wrapped in a soap envelope.

从http://www.w3schools.com/xml/xml_soap.asp开始,将您的内容重新整理成肥皂信封。