Ruby on rails HTTP发送请求xml
我需要以xml的形式发送请求Ruby on rails HTTP发送请求xml,ruby-on-rails,xml,request,uri,Ruby On Rails,Xml,Request,Uri,我需要以xml的形式发送请求 uri =URI('https://fs.example.com:8443/services/trust/13/usermixed') http = Net::HTTP.new(uri) request = Net::HTTP::Post.new(uri) request['Content-Type'] = 'application/soap+xml; charset=UTF-8' request.body = @body(as xml) response = ht
uri =URI('https://fs.example.com:8443/services/trust/13/usermixed')
http = Net::HTTP.new(uri)
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/soap+xml; charset=UTF-8'
request.body = @body(as xml)
response = http.request(request)
在方法Net::HTTP::Post.new
hooks端口80末尾向uri发送请求时,结果是https://fs.example.com:8443/services/trust/13/usermixed:80
这会导致错误SocketError:无法打开到的TCP连接https://fs.example.com:8443/services/trust/13/usermixed:80 (getaddrinfo:名称或服务未知)
通过方法Net::HTTP.post_form(uri,数据)
在末尾没有端口解决了类似的问题。。。但它只能通过散列来确定日期。我需要将request.body发送到XML
谢谢 当您想要启动一个新的
http
会话时,让我们只使用基本URL,并将请求发送到普通URL
uri = URI('https://fs.example.com:8443/services/trust/13/usermixed')
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.to_s)
request['Content-Type'] = 'application/soap+xml; charset=UTF-8'
request.body = @body(as xml)
response = http.request(request)
然后请求应该按预期工作