【发布时间】:2016-04-30 17:20:52
【问题描述】:
我想通过 net/http 使用此 WSDL http://www.webservicex.net/uszip.asmx?WSDL 的 GetInfoByZIP 服务,但总是收到错误“服务器无法识别 HTTP 标头 SOAPAction 的值”
path = '/uszip.asmx'
#http://www.webservicex.net/uszip.asmx?WSDL
# Create the SOAP Envelope
data = <<-EOF
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetInfoByZIPResponse xmlns="http://www.webserviceX.NET">
<GetInfoByZIPResult>
<NewDataSet xmlns="">
<Table>
<CITY>Beverly Hills</CITY>
<STATE>CA</STATE>
<ZIP>90210</ZIP>
<AREA_CODE>310</AREA_CODE>
<TIME_ZONE>P</TIME_ZONE>
</Table>
</NewDataSet>
</GetInfoByZIPResult>
</GetInfoByZIPResponse>
</soap:Body>
</soap:Envelope>EOF
host = "www.webservicex.net"
http = Net::HTTP.new(host)
resp = http.post(path, data, { 'Content-Type' => 'text/xml; charset=utf-8', 'SOAPAction' => 'GetInfoByZIP' })
谁能帮帮我? 谢谢
【问题讨论】:
标签: ruby web-services soap wsdl net-http