0
我擁有在Mac和Linux上運行的相同Web應用程序。SOAPAction爲空
在Mac上,我使用的是Savon 0.7.6,並且Web應用程序運行完美;應用程序啓動SOAP請求如下:
client = Savon::Client.new("http://pvwatts.nrel.gov/PVWATTS.asmx?WSDL")
req = prep_request(@locationId, @dc_rating, @tilt, @azimuth, @derate, @array_type, @cost)
response = client.get_pvwatts{|soap| soap.input = "GetPVWATTS"; soap.body = req }
rdata = response.to_hash
導致以下請求:
Retrieving WSDL from: http://pvwatts.nrel.gov/PVWATTS.asmx?WSDL
SOAP request: http://pvwatts.nrel.gov/PVWATTS.asmx
SOAPAction: http://pvwatts.nrel.gov/GetPVWATTS, Content-Type: text/xml;charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:wsdl="http://pvwatts.nrel.gov" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><wsdl:GetPVWATTS><wsdl:derate>0.8</wsdl:derate><wsdl:latitude>-99.0</wsdl:latitude><wsdl:pwrdgr>-0.005</wsdl:pwrdgr><wsdl:cost>0.1</wsdl:cost><wsdl:locationID>23234</wsdl:locationID><wsdl:inoct>45.0</wsdl:inoct><wsdl:mode>0</wsdl:mode><wsdl:key><key></wsdl:key><wsdl:azimuth>230</wsdl:azimuth><wsdl:tilt>20</wsdl:tilt><wsdl:DCrating>1</wsdl:DCrating><wsdl:longitude>0.0</wsdl:longitude></wsdl:GetPVWATTS></env:Body></env:Envelope>
注意SOAPAction域被填充
在Linux上,我用薩翁版本1.2.0使用以下語法:
client = Savon::Client.new do
wsdl.document = "http://pvwatts.nrel.gov/PVWATTS.asmx?WSDL"
end
req = prep_request(@locationId, @dc_rating, @tilt, @azimuth, @derate, @array_type, @cost)
response = client.request :wsdl, "GetPVWATTS" do
soap.body = req
end
rdata response.to_hash
這會導致以下錯誤:
SOAP request: http://pvwatts.nrel.gov/PVWATTS.asmx
Content-Length: 750, Content-Type: text/xml;charset=UTF-8, SOAPAction: ""
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://pvwatts.nrel.gov" xmlns:wsdl="http://pvwatts.nrel.gov"><env:Body><ins0:GetPVWATTS><wsdl:inoct>45.0</wsdl:inoct><wsdl:tilt>20</wsdl:tilt><wsdl:cost>0.1</wsdl:cost><wsdl:locationID>23234</wsdl:locationID><wsdl:mode>0</wsdl:mode><wsdl:DCrating>1</wsdl:DCrating><wsdl:key><key></wsdl:key><wsdl:pwrdgr>-0.005</wsdl:pwrdgr><wsdl:latitude>-99.0</wsdl:latitude><wsdl:azimuth>180</wsdl:azimuth><wsdl:longitude>0.0</wsdl:longitude><wsdl:derate>0.8</wsdl:derate></ins0:GetPVWATTS></env:Body></env:Envelope>
SOAP response (status 500):
<?xml version="1.0" encoding="utf-8"?><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><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
Completed 500 Internal Server Error in 1065ms
Savon::SOAP::Fault ((soap:Client) Server did not recognize the value of HTTP Header SOAPAction: .):
請注意,不填充SOAPAction字段。
任何人都可以告訴我這裏有什麼問題嗎?