我被迫使用Savon進入肥皂世界並遇到一些問題。將原始XML查詢轉換爲Savon 2格式
的WSDL是:http://evernet.nwmls.com/evernetqueryservice/evernetquery.asmx?wsdl 如果我使用的測試形式爲這個數據提供者,我可以使用以下格式無錯誤地接收數據:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<EverNetQuerySpecification xmlns="urn:www.nwmls.com/Schemas/General/EverNetQueryXML.xsd">
<Message>
<Head>
<UserId>my_username_here</UserId>
<Password>my_password_here</Password>
<SchemaName>StandardXML1_2</SchemaName>
</Head>
<Body>
<Query>
<MLS>nwmls</MLS>
<PropertyType>RESI</PropertyType>
<BeginDate>2014-04-20T00:25:00</BeginDate>
<EndDate>2014-04-22T00:25:00</EndDate>
</Query>
<Filter />
</Body>
我試圖與薩翁2.2複製這個在我的Rails應用程序是:
client = Savon.client(:wsdl => "http://evernet.nwmls.com/evernetqueryservice/evernetquery.asmx?wsdl")
response = client.call(:retrieve_listing_data) do |locals|
locals.message "Query" => {"Head" => {"UserId" => "my_username_here", "Password" => "my_password_here", "SchemaName" => "StandardXML1_2"}, "Body" => {"MLS" => "nwmls", "PropertyType" => "RESI", "BeginDate" => "2014-04-17T00:25:00", "EndDate" => "2014-04-22T00:25:00"}}
end
但我收到一個錯誤說:
Value cannot be null. Parameter name: s
我在什麼肥皂有點失落,但特別是在這裏丟失,因爲它似乎是我,包括我的薩翁語法的一切,但必須失去了一些東西......
編輯:這裏的在調試的全部xml響應上:
D, [2014-04-22T16:55:52.806716 #77213] DEBUG -- : HTTPI GET request to evernet.nwmls.com (net_http)
I, [2014-04-22T16:55:54.340990 #77213] INFO -- : SOAP request: http://evernet.nwmls.com/evernetqueryservice/evernetquery.asmx
I, [2014-04-22T16:55:54.341077 #77213] INFO -- : SOAPAction: "http://www.nwmls.com/EverNetServices/RetrieveListingData", Content-Type: text/xml;charset=UTF-8, Content-Length: 682
D, [2014-04-22T16:55:54.341120 #77213] DEBUG -- : <?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:tns="http://www.nwmls.com/EverNetServices" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:RetrieveListingData><tns:Query><tns:Head><tns:Head>hoverboard</tns:Head><tns:Password>cP6cHias</tns:Password><tns:SchemaName>StandardXML1_2</tns:SchemaName></tns:Head><tns:Body><tns:MLS>nwmls</tns:MLS><tns:PropertyType>RESI</tns:PropertyType><tns:BeginDate>2014-04-17T00:25:00</tns:BeginDate><tns:EndDate>2014-04-22T00:25:00</tns:EndDate></tns:Body></tns:Query></tns:RetrieveListingData></env:Body></env:Envelope>
D, [2014-04-22T16:55:54.341255 #77213] DEBUG -- : HTTPI POST request to evernet.nwmls.com (net_http)
I, [2014-04-22T16:55:54.678125 #77213] INFO -- : SOAP response (status 200)
D, [2014-04-22T16:55:54.678292 #77213] DEBUG -- : <?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><RetrieveListingDataResponse xmlns="http://www.nwmls.com/EverNetServices"><RetrieveListingDataResult><Listings>
<ResponseMessages>
<Message>Value cannot be null.
Parameter name: s</Message>
</ResponseMessages>
</Listings></RetrieveListingDataResult></RetrieveListingDataResponse></soap:Body></soap:Envelope>
=> #<Savon::Response:0x007f844230e4e0 @http=#<HTTPI::Response:0x007f844230fc00 @code=200, @headers={"cache-control"=>"private, max-age=0", "content-type"=>"text/xml; charset=utf-8", "server"=>"Microsoft-IIS/7.5", "x-aspnet-version"=>"4.0.30319", "x-powered-by"=>"ASP.NET", "date"=>"Tue, 22 Apr 2014 23:55:54 GMT", "content-length"=>"574"}, @raw_body="<?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><RetrieveListingDataResponse xmlns=\"http://www.nwmls.com/EverNetServices\"><RetrieveListingDataResult><Listings>\r\n <ResponseMessages>\r\n <Message>Value cannot be null.\r\nParameter name: s</Message>\r\n </ResponseMessages>\r\n</Listings></RetrieveListingDataResult></RetrieveListingDataResponse></soap:Body></soap:Envelope>", @body="<?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><RetrieveListingDataResponse xmlns=\"http://www.nwmls.com/EverNetServices\"><RetrieveListingDataResult><Listings>\r\n <ResponseMessages>\r\n <Message>Value cannot be null.\r\nParameter name: s</Message>\r\n </ResponseMessages>\r\n</Listings></RetrieveListingDataResult></RetrieveListingDataResponse></soap:Body></soap:Envelope>">, @globals=#<Savon::GlobalOptions:0x007f8447489a40 @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{}, :logger=>#<Logger:0x007f84474899c8 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007f84474899a0 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x007f8447489950 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007f8447489928 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007f84474898d8>>>>, :log=>true, :filters=>[], :pretty_print_xml=>false, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:[email protected]/Users/seth/.rvm/gems/ruby-2.0.0-p195/gems/savon-2.4.0/lib/savon/options.rb:56 (lambda)>, :multipart=>false, :wsdl=>"http://evernet.nwmls.com/evernetqueryservice/evernetquery.asmx?wsdl"}>, @locals=#<Savon::LocalOptions:0x007f84443732a8 @option_type=:local, @options={:advanced_typecasting=>true, :response_parser=>:nokogiri, :multipart=>false, :message=>{"Query"=>{"Head"=>{"Head"=>"my_username", "Password"=>"my_password", "SchemaName"=>"StandardXML1_2"}, "Body"=>{"MLS"=>"nwmls", "PropertyType"=>"RESI", "BeginDate"=>"2014-04-17T00:25:00", "EndDate"=>"2014-04-22T00:25:00"}}}}>>
感謝您的提示。我已經用完整的回覆更新了我的問題。我得到一個200但神祕的不是關於某些值不能爲空。 – SethS
現在是大槍的時候了:-)。第1步:使用SoapUI創建一個有效的請求。第2步:在Ruby/Savon中重建請求。這將是解決問題的標準方法。顯然,系統不會返回有意義的錯誤消息。 (不幸的是並不罕見)。 –