我最近开始研究ruby。我使用curb gem为SOAP客户端请求和响应编写了一个小代码。但我在响应XML时遇到了一些错误。
代码:
require 'curb'
c = Curl::Easy.new('http://api.abc.com/service.asmx?wsdl&apikey='+key)
c.multipart_form_post = true
c.http_post(Curl::PostField.content('SOAPAction', 'http://api.abc.com/GetServices'))
c.http_post(Curl::PostField.content('Content-Type', 'application/soap+xml; charset=utf-8'))
c.http_post(Curl::PostField.content('Content-Length', '200'))
c.http_post(Curl::PostField.file('rovi', '/path/data.xml'))
puts c.body_str
错误:
<soap:Text xml:lang="en">Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1.</soap:Text>
提前致谢