luxre / nwmls

MIT License
10 stars 9 forks source link

Authentication Question #1

Closed Siggs2000 closed 10 years ago

Siggs2000 commented 10 years ago

First, I wanted to say thanks for making this an open source gem! I've been droning through savon for most of the day, dealing with this odd soap MLS.

Now a question: I've installed the gem and added the initializer file called nwmls.rb that contains just this:

Evernet::Connection.user = 'my_username'
Evernet::Connection.pass = 'my_password'

(Obviously I have our real username and password in there)

When I go into the rails console for some testing, I'm trying this to kick it off:

Nwmls::Listing.find(:property_type => “RESI”, :status => “A”, :city => “Seattle”)

and this Nwmls::Listing.find(:listing_number => '622424')

Both (and any) commands I'm trying are returning this error:

D, [2014-04-21T20:47:30.278254 #51567] DEBUG -- : HTTPI GET request to evernet.nwmls.com (net_http)
I, [2014-04-21T20:47:33.983275 #51567]  INFO -- : SOAP request: http://evernet.nwmls.com/evernetqueryservice/evernetquery.asmx
I, [2014-04-21T20:47:33.983352 #51567]  INFO -- : SOAPAction: "http://www.nwmls.com/EverNetServices/RetrieveListingData", Content-Type: text/xml;charset=UTF-8, Content-Length: 971
D, [2014-04-21T20:47:33.983395 #51567] 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:v_strXmlQuery>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;EverNetQuerySpecification xmlns=&quot;urn:www.nwmls.com/Schemas/General/EverNetQueryXML.xsd&quot;&gt;&lt;Message&gt;&lt;Head&gt;&lt;UserId&gt;XXXX&lt;/UserId&gt;&lt;Password&gt;XXXXX&lt;/Password&gt;&lt;SchemaName&gt;StandardXML1_1&lt;/SchemaName&gt;&lt;/Head&gt;&lt;Body&gt;&lt;Query&gt;&lt;MLS&gt;NWMLS&lt;/MLS&gt;&lt;ListingNumber&gt;622424&lt;/ListingNumber&gt;&lt;PropertyType&gt;RESI&lt;/PropertyType&gt;&lt;/Query&gt;&lt;Filter&gt;&lt;/Filter&gt;&lt;/Body&gt;&lt;/Message&gt;&lt;/EverNetQuerySpecification&gt;</tns:v_strXmlQuery></tns:RetrieveListingData></env:Body></env:Envelope>
D, [2014-04-21T20:47:33.983499 #51567] DEBUG -- : HTTPI POST request to evernet.nwmls.com (net_http)
I, [2014-04-21T20:47:34.317266 #51567]  INFO -- : SOAP response (status 200)
D, [2014-04-21T20:47:34.317396 #51567] 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>&lt;Listings xmlns="http://www.nwmls.com/Schemas/Standard/StandardXML1_1.xsd"&gt;
  &lt;ResponseMessages&gt;
    &lt;Message&gt;Unable to validate UserId/Password combination.&lt;/Message&gt;
  &lt;/ResponseMessages&gt;
&lt;/Listings&gt;</RetrieveListingDataResult></RetrieveListingDataResponse></soap:Body></soap:Envelope>
NoMethodError: undefined method `inner_text' for nil:NilClass
bobdutch commented 10 years ago

I get that same error when I change our password to something invalid. I'll make an issue to handle that response.

Did you try Evernet::Connection.user in the console, just to make sure the initializer is setting the vars?

Have you successfully authenticated with any other SOAP clients? I suspect the issue is with your password (remember that the ftp user/password is different than the web service).

Siggs2000 commented 10 years ago

Thanks for getting back on this Bob!

I did try to declare the vars in the console too.

Oddly, the username / password combo works in the NWMLS test form though.

I was trying to troubleshoot by testing it out in Savon but I don't think I have the format for that quite right. I'm getting other errors in savon, but that's a whole other story, I think.

I feel like I must be missing some step. Is there any type of auth call that needs to be made first from the console? Or do I jump straight into making queries?

bobdutch commented 10 years ago

I don't recall any auth steps we had to take. I think you should be able to make queries right away. I was able to connect the evernet with Soap UI that's linked from this railscast. http://railscasts.com/episodes/290-soap-with-savon

Can you provide a link to the nwmls test form? I want to try that myself.

bobdutch commented 10 years ago

take a look at the code in https://github.com/luxre/nwmls/blob/master/app/models/evernet/connection.rb to see how we connect with Savon

Siggs2000 commented 10 years ago

Here's that test form: http://evernet.nwmls.com/evernettest/RetrieveListingData.aspx

Siggs2000 commented 10 years ago

I see what's wrong. We only have access to StandardXML1_2

Do you support that schema? I'll contact NWMLS to get access to 1.1 anyway.

bobdutch commented 10 years ago

I tried setting Evernet::Connection.schema_name = 'StandardXML1_2' in my initializer. I'm getting a nil response. It might be because we don't have access to 1.2. Does that work for you?

Siggs2000 commented 10 years ago

If I change the schema to 1.2, I actually get this message:

NoMethodError: undefined method `call' for #Savon::Client:0x007fd81cf61020 on this call:

Nwmls::Listing.find(:listing_number => '622424')

And this: NameError: undefined local variable or method `“RESI”' for main:Object on this call:

Nwmls::Listing.find(:property_type => “RESI”, :status => “A”, :city => “Seattle”)

Just waiting on NWMLS to approve our username for 1.1. There must be some pretty significant differences between 1.1 and 1.2.

bobdutch commented 10 years ago

with

Nwmls::Listing.find(:listing_number => '622424')

I get RuntimeError: code EPSEnergy not found which means we haven't set up mapping for that element to an attribute yet.

I'll look into support for 1.2. I'm guessing it's just a few new fields and we should have support for it soon.


Nwmls::Listing.find(:property_type => "RESI", :status => "A", :city => "Seattle")

this one had a problem with quotation marks. Try copying it again.

Siggs2000 commented 10 years ago

Thanks again. This should probably work once I get access to 1.1.

As far as that query goes, I just copied that from the readme, I believe.

Again, thanks for providing the gem as open source! I'll update and close this once I test it out with the new 1.1 access plus I'll keep my eyes peeled for the new 1.2 support.

bobdutch commented 10 years ago

Yes it looks like the markdown in the README changed the quotation marks into curly quotes. I'll fix that.

Good luck with 1.1. I'm curious why you're not getting the same errors as me. Which version of rails are you using?

Siggs2000 commented 10 years ago

I'm using Rails 4.0.0 to make the gem requirements happy. (We were using 4.1.0 before)

Update: Just got a call from NWMLS saying they won't give new access to 1.1 anymore as they are pushing everyone to upgrade... Gotta love MLS's!

I'll keep an eye on this gem to watch for 1.2 compatibility and go at Savon for now!

Edit: I see what you mean by the curly quotes. You're right - when I change to regular quotation marks, I get the same error as the other query. (undefined method `call' for #Savon::Client:0x007fd8a9fbaae8)

bobdutch commented 10 years ago

@Siggs2000 I've added support for Rails 4.1 and the Standard1_2 schema. I'd love it if you could give the gem a try again.

Siggs2000 commented 10 years ago

Thanks Bob, I'll check it out!

Siggs2000 commented 10 years ago

Hey @bobdutch I'm finally back to working on the NWMLS integration and of course, this gem is now working like a charm with 1.2 and Rails 4.1. Thanks for the update!

Any tips on a good flow to dealing with the images? I'm not totally sure how to get the actual file to handle.

I'll close this issue for now though since the original question is solved. Thanks again!