0
我試圖做一個SOAP POST請求eBay的Web服務添加一項要求:紅寶石後請求失敗,錯誤的getaddrinfo
require 'uri'
require 'net/https'
# Create the http object
http = Net::HTTP.new('https://api.sandbox.ebay.com', 443)
http.use_ssl = true
path = '/wsapi?callname=AddItem&siteid=0&version=733&Routing=new'
# Create the SOAP Envelope
data = <<-eot
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ebay:apis:eBLBaseComponents">
<soapenv:Header>
<urn:RequesterCredentials>
<urn:eBayAuthToken>TOKEN HERE</urn:eBayAuthToken>
<urn:Credentials>
<urn:AppId>APP_ID</urn:AppId>
<urn:DevId>DEV_ID</urn:DevId>
<urn:AuthCert>AUTH_CERT</urn:AuthCert>
</urn:Credentials>
</urn:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<urn:AddItemRequest>
<urn:DetailLevel>ReturnAll</urn:DetailLevel>
<urn:ErrorLanguage>en_US</urn:ErrorLanguage>
<urn:Version>733</urn:Version>
</urn:AddItemRequest>
</soapenv:Body>
</soapenv:Envelope>
eot
# Set Headers
header = {
'Accept-Encoding' => 'gzip,deflate',
'Content-Type' => 'text/xml;charset=UTF-8',
'Host' => 'api.sandbox.ebay.com',
'Connection' => 'Keep-Alive',
'SOAPAction' => '',
'Content-Lenth' => '160000',
"X-EBAY-SOA-MESSAGE-PROTOCOL" => "SOAP12",
"X-EBAY-SOA-SECURITY-APPNAME" => "APP_ID_HERE"}
# Post the request
resp, data_end = http.post(path, data, header)
# Output the results
puts 'Code = ' + resp.code
puts 'Message = ' + resp.body
resp.each { |key, val| puts key + ' = ' + val }
puts data_end
我是有工作的一瞬間。現在,當我在Ubuntu的終端上運行IRB中的代碼時,我總是收到getaddrinfo錯誤。
我正在玩創建套接字,我認爲這就是我如何工作。但是當我嘗試重新創建套接字時,我不能再複製結果。
是否有更好的環境啓動此代碼?我應該不得不惹惱套接字?
Ruby不具有HTTP請求內置的那種配置嗎?如果套接字是這個問題的重要組成部分,我應該研究哪些話題?有沒有一個很好的資源可以告訴我如何設置套接字連接?
你看過[Savon](http://savonrb.com/)嗎? 這是我知道的Ruby唯一倖存的SOAP Gem。 –
你正在得到什麼確切的錯誤? – xaxxon
getaddrinfo聽起來像是一個dns問題。主機是否在紅寶石之外解決? –