zenchild/Viewpoint — pull request #32 by geoffwa (2012-01-01 08:21:21+00:00)
Title: MailboxUser.find_user breaks if user is also in auth'd user's contacts

In the following scenario:

* authenticated as me@mycompany.com
* me@mycompany.com has me@mycompany.com as a contact

Then if I issue:

```ruby
include Viewpoint::EWS
EWS.endpoint = 'https://mycompany.com/ews/exchange.asmx'
EWS.set_auth('me@mycompany.com', 'password')
MailboxUser.find_user('me@mycompany.com')
```

I get a NilClass error:

```
/Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parsers/ews_parser.rb:219:in `contact': undefined method `native_element' for nil:NilClass (NoMethodError)
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parsers/ews_parser.rb:232:in `block in resolution_set'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parsers/ews_parser.rb:228:in `each'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parsers/ews_parser.rb:228:in `resolution_set'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parsers/ews_parser.rb:29:in `resolve_names_response'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parser.rb:44:in `call'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/parser.rb:44:in `parse'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/ews_service.rb:774:in `parse!'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/soap/handsoap/ews_service.rb:119:in `resolve_names'
from /Users/geoffwa/.rvm/gems/ruby-1.9.3-p0/gems/viewpoint-0.1.26/lib/model/mailbox_user.rb:36:in `find_user'
```

It looks like ResolveNames is also returning the auth'd users contact, which breaks EwsParser as it expects all entities to have a child.

I worked this by skipping entities with no . This should work okay until we want to start searching for users who *are* contacts.

The returned SOAP response for the case above looks something like:

```xml

me@mycompany.com
me@mycompany.com
SMTP
Mailbox

me@mycompany.com
me@mycompany.com
SMTP
Contact

```