LoginSignup
28
31

More than 5 years have passed since last update.

RubyでSOAP通信を行う方法

Posted at

rubyでSOAP通信する方法。

sample.rb
require "net/http"
require "uri"
require "rexml/document"

uri = URI.parse("APIのURL")

response = nil

request = Net::HTTP::Post.new(uri.request_uri)
request.body = <<EOS
<?xml version="1.0" encoding="UTF-8"?> 
・
・
・
・
・
・
・
・
EOS

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

http.set_debug_output $stderr

http.start do |h|
  response = h.request(request)
end

puts response.body

以上のスクリプトを実行するとコンソールに取得結果のXMLが出力される。

28
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
31