stamps icon indicating copy to clipboard operation
stamps copied to clipboard

The property 'address' is not defined for this Trash

Open ayb opened this issue 12 years ago • 37 comments

Running into a similar issue to another that has been reported but different property (and newer version of the WSDL)

This is happening when I run the Stamps.create! action. Here is the output I am getting:

SOAP request: https://swsim.testing.stamps.com/swsim/SwsimV23.asmx
SoapAction: http://stamps.com/xml/namespace/2012/04/swsim/swsimv23/AuthenticateUser, Content-Type: 
text/xml;charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:tns="http://stamps.com/xml/namespace/2012/04/swsim/swsimv23"
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:AuthenticateUser>
 <tns:Credentials><tns:IntegrationID>[MY-INTEGRATION-ID-HERE]</tns:IntegrationID><tns:Username>[MY
 -USERNAME-HERE]</tns:Username><tns:Password>[MY-PASSWORD-HERE]</tns:Password>
 </tns:Credentials></tns:AuthenticateUser></soap:Body></soap:Envelope>

SOAP response (status 200):

 <?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><AuthenticateUserResponse
  xmlns="http://stamps.com/xml/namespace/2012/04/swsim/swsimv23">
 <Authenticator>exp=1344609632&amp;uid=2799981&amp;cty=swsim&amp;
 ctk=AAuJ3tJa7M5ALfsNktPX99CJOoM=&amp;iid=6LKmNRnJxEyDQfY5lUwNVw==
 &amp;rsid=0&amp;eac=0&amp;eacx=0&amp;rrsid=0&amp;raid=0&amp;resellerid=0
 &amp;pexp=0&amp;mac=Yf9kPx+hNYoX5po8vIOrCbHWgaQ=</Authenticator>
 <LastLoginTime>2012-08-09T14:38:58.12</LastLoginTime><ClearCredential>false</ClearCredential>
 <LoginBannerText /><PasswordExpired>false</PasswordExpired></AuthenticateUserResponse></soap:Body>
 </soap:Envelope>

NoMethodError: The property 'address' is not defined for this Trash. from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/trash.rb:50:in property_exists?' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/trash.rb:35:in[]=' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:83:in block in initialize' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:82:ineach_pair' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:82:in initialize' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/stamps-0.3.0/lib/stamps/mapping.rb:126:innew' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/stamps-0.3.0/lib/stamps/mapping.rb:126:in to=' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/trash.rb:34:in[]=' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:83:in block in initialize' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:82:ineach_pair' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/hashie-1.0.0/lib/hashie/dash.rb:82:in initialize' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/stamps-0.3.0/lib/stamps/client/stamp.rb:32:innew' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/stamps-0.3.0/lib/stamps/client/stamp.rb:32:in create!' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/stamps-0.3.0/lib/stamps.rb:25:inmethod_missing' from (irb):28 from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/railties-3.1.7/lib/rails/commands/console.rb:45:in start' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/railties-3.1.7/lib/rails/commands/console.rb:8:instart' from /Users/ayb/.rvm/gems/ruby-1.9.2-p290@stack/gems/railties-3.1.7/lib/rails/commands.rb:40:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `

'>>

ayb avatar Aug 09 '12 14:08 ayb

I went through some code and thought I could resolve it by simply making a minor tweak and using standardized_address[:address] instead:

 stamp = Stamps.create!(
     :tracking_number => true,
     :rate          => rates.first,
     :to            => standardized_address[:address],
     :from => {
     :full_name   => 'Littlelines',
     :address1    => '50 Chestnut Street',
     :address2    => 'Suite 234',
     :city        => 'Beavervcreek',
     :state       => 'OH',
     :zip_code    => '45440'
   },
   :memo => 'Thanks for shopping with us!'
)

But now I am running into a different error:

 {:errors=>["Invalid SOAP message due to XML Schema validation failure. The element 'CreateIndicium' in namespace 'http://stamps.com/xml/namespace/2012/04/swsim/swsimv23' has invalid child element 'TrackingNumber' in namespace 'http://stamps.com/xml/namespace/2012/04/swsim/swsimv23'. List of possible elements expected: 'IntegratorTxID' in namespace 'http://stamps.com/xml/namespace/2012/04/swsim/swsimv23'."], :valid?=>false}

Guessing they have made some changes to the API between v12 and the current v23?

ayb avatar Aug 09 '12 15:08 ayb

Have you tried setting the endpoint to v12? Like this:

config.endpoint = "https://swsim.testing.stamps.com/swsim/swsimv12.asmx"

(Within the configure block)

mattsears avatar Aug 09 '12 23:08 mattsears

We are getting the same error using any/all versions including 12. We are able to standardize and address and perform a get rates, but when we try to create a label with that information, it blows up on us giving us the same error as above. Thoughts?

git-odi avatar Sep 13 '12 20:09 git-odi

Can you post your config (omit sensitive values)?

mattsears avatar Sep 13 '12 20:09 mattsears

I am having the same problem. I can assist as well. I'm guessing that the wsdl is out of date and we need to update the data in types.rb.

I can provide you with the latest wsdl, reflecting v24, not v12.

mr-rick avatar Sep 13 '12 20:09 mr-rick

From what I understand, the error also occurs with v12 of the wsdl?

mattsears avatar Sep 13 '12 21:09 mattsears

I cannot test v12 for some reason. I have a brand new stamps.com integration_id and it seems I only have access to v24. When I change to v12, I get a login error.

mr-rick avatar Sep 13 '12 21:09 mr-rick

Here is my current setup:

Stamps.configure do |config|
    config.integration_id = 'ID'
    config.username       = 'USERNAME'
    config.password       = 'PASSWORD'
    config.raise_errors   = true
    config.endpoint       = 'https://swsim.testing.stamps.com/swsim/swsimv12.asmx'
  end
    from_address = Stamps.clean_address(
      :address => {
        :full_name => 'Chipotle',
        :address1  => '801 Congress Avenue',
        :city      => 'Austin',
        :state     => 'TX',
        :zip_code  => '78701'
    })
    
    to_address = Stamps.clean_address(
      :address => {
        :full_name   => 'Freebirds',
        :address1    => '515 South Congress Avenue',
        :city        => 'Austin',
        :state       => 'TX',
        :zip_code    => '78704'
    })
  
    # send one burrito
    rates = Stamps.get_rates(
      :from_zip_code => '78701',
      :to_zip_code   => '78704',
      :weight_lb     => '0.5',
      :ship_date     => '2012-09-14'
    )
  
    stamp = Stamps.create!(
        :tracking_number  => true,
        :rate             => rates.first,
        :to               => to_address[:address],
        :from             => from_address[:address],
        :memo             => 'Thanks for shopping with us!'
    )

Here is the error I get:

(soap:Client) Invalid SOAP message due to XML Schema validation failure. The element 'CreateIndicium' in namespace 'http://stamps.com/xml/namespace/2010/11/swsim/swsimv12' has invalid child element 'TrackingNumber' in namespace 'http://stamps.com/xml/namespace/2010/11/swsim/swsimv12'. List of possible elements expected: 'IntegratorTxID' in namespace 'http://stamps.com/xml/namespace/2010/11/swsim/swsimv12'.

git-odi avatar Sep 13 '12 21:09 git-odi

ok, so I've updated my code to reflect the same format as darnavo's Stamps.create method and here is my response, converted to yaml format:


:errors:

  • !ruby/string str: ! 'Invalid SOAP message due to XML Schema validation failure. The element ''CreateIndicium'' in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24'' has invalid child element ''TrackingNumber'' in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24''. List of possible elements expected: ''IntegratorTxID'' in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24''.' attributes: {} :valid?: false

mr-rick avatar Sep 13 '12 21:09 mr-rick

If I comment out the tracking_number = true, here is the error I get:

mr-rick avatar Sep 13 '12 21:09 mr-rick

what error ^^ ?

git-odi avatar Sep 13 '12 21:09 git-odi

sorry, here it is...

---
:errors:
- !ruby/string
  str: ! 'Invalid SOAP message due to XML Schema validation failure. The element ''CreateIndicium''
    in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24'' has invalid
    child element ''Rate'' in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24''.
    List of possible elements expected: ''IntegratorTxID'' in namespace ''http://stamps.com/xml/namespace/2012/05/swsim/swsimv24''.'
  attributes: {}
:valid?: false

mr-rick avatar Sep 13 '12 21:09 mr-rick

yes, same thing for me as well.

git-odi avatar Sep 13 '12 22:09 git-odi

When I comment out the "Rate" attribute, I get an error complaining about the "From" field.

mr-rick avatar Sep 13 '12 22:09 mr-rick

I don't know if it helps, but my only guess is that you are using outdated wsdl data or something is up with mapping.rb. If I was more experienced with wsdl and soap technology, I would be of better help.

mr-rick avatar Sep 13 '12 22:09 mr-rick

I have found a ruby gem called wasabi that can consume a wsdl file. It may be worthwhile using something like that so that we can add an option to load up a wsdl file for the corresponding version of the namespace and endpoint URL's

I was able to load up the stamps.com wsdl using wasabi successfully, in addition to being able to see the output of the wsdl in yaml format using the .to_yaml call (requiring the yaml gem).

mr-rick avatar Sep 13 '12 22:09 mr-rick

I've tried modifying request.rb to use the wsdl file and I still get the same error. Here is my modification:

    def request(web_method, params, raw=false)
      client = Savon::Client.new do |wsdl, http|
        #wsdl.endpoint = self.endpoint
        #wsdl.namespace = self.namespace
        wsdl.document = "swsimv24.wsdl"
      end

mr-rick avatar Sep 13 '12 22:09 mr-rick

I contacted stamps.com support and this was their feedback:


You are not including the "IntegratorTxID" in your CreateIndicium request. That element would go just prior to TrackingNumber and is a unique identifier you create.

mr-rick avatar Sep 13 '12 23:09 mr-rick

Ok, so I added a transaction_id

puts "creating stamp"
stamp = Stamps.create!(
    :transaction_id => 'blah',
    :memo => 'Thanks for shopping with us!',
    :tracking_number => true,
    :rate          => rates.first,
    :to            => to_address[:address],
    :from          => from_address[:address]
)


and hear is the new output in yaml format:
```yaml
---
:errors:
- !ruby/string
  str: ! 'Deprecated Method Input:  Web method deprecated for this specific use from
    interface version [22] onwards'
  attributes: {}
:valid?: false

mr-rick avatar Sep 13 '12 23:09 mr-rick

So I added transaction_id to Stamps.create! in the configuration I pasted above:


stamp = Stamps.create!(
    :transaction_id   => "193193",
    :tracking_number  => true,
    :rate             => rates.first,
    :to               => to_address[:address],
    :from             => from_address[:address],
    :memo             => 'Thanks for shopping with us!'
)

and now I get this error message:

(soap:Server) Memo is not supported for First Class Mail with Letter or Postcard.

Which means it may have worked, but I may be requesting an unsupported service. I will play around a bit more.

git-odi avatar Sep 13 '12 23:09 git-odi

Ok, I've got it working I believe with the right :service_type

puts "getting rate quote"
rates = Stamps.get_rates(
  :from_zip_code => '90291',
  :to_zip_code   => '20500',
  :weight_lb     => '0.5',
  :service_type  => "US-PP",
  :ship_date     => '2012-09-14'
)
puts "creating stamp"
stamp = Stamps.create!(
    :transaction_id => 'blah',
    :tracking_number => true,
    :rate          => rates.first,
    :to            => to_address[:address],
    :from          => from_address[:address]
)

Here is the output in yaml format, which I think is something I have to get stamps.com to fix:
```yaml
creating stamp
---
:errors:
- !ruby/string
  str: Insufficient Postage
  attributes: {}
:valid?: false

mr-rick avatar Sep 14 '12 00:09 mr-rick

Nice, indeed it looks like it is working. What did you do to get around the "The property 'address' is not defined" error?

mattsears avatar Sep 14 '12 00:09 mattsears

To get around the "The property 'address' is not defined", I had to use the below format, where to_address and from_address are return values from the Stamps.clean_address call.

Here is what I'm using in the Stamps.create! call:

:to            => to_address[:address],
:from          => from_address[:address]

mr-rick avatar Sep 14 '12 00:09 mr-rick

I don't know if it's making a difference, but I'm not using self.endpoint and self.namespace anymore. I'm loading the full wsdl file when invoking/instantiating Savon::Client.new... I'm setting wsdl.document to the location of the wsdl on my server.

mr-rick avatar Sep 14 '12 00:09 mr-rick

No, it does not matter. When I remove the code to load the wsdl and revert back to using self.endpoint and self.namespace, it works fine. So it appears we don't need to load the full wsdl at this point.

mr-rick avatar Sep 14 '12 00:09 mr-rick

You shouldn't have to run the :from address through Stamps.clean_address. Do you know if you just use the Stamps.clean_address on the :to address will it work?

mattsears avatar Sep 14 '12 01:09 mattsears

I did that originally from your documentation. I imagine that what ever object is returned by from_address[:address] call seems to be what works. All you'd need to do is figure out what object is returned form that and recreate the format, and I'm sure you wouldn't need to clean the from address.

mr-rick avatar Sep 14 '12 01:09 mr-rick

I see. Thanks for your help with this.

mattsears avatar Sep 14 '12 02:09 mattsears

How do I use AddOnV2??

I want to add this addon to a get rate call: US-A-DC

US-A-DC is a delivery confirmation addon.

Thanks!

On Thu, Sep 13, 2012 at 7:07 PM, Matt Sears [email protected]:

I see. Thanks for your help with this.

— Reply to this email directly or view it on GitHubhttps://github.com/mattsears/stamps/issues/11#issuecomment-8549899.

mr-rick avatar Sep 14 '12 02:09 mr-rick

Add ons go in the :rate hash of the stamp. Something like this....

stamp = Stamps.create!({
    :sample          => true,
    :transaction_id  => "1234567890ABCDEFG",
    :tracking_number => true,
    :rotation        => 90,
    :rate          => {
      :from_zip_code => '45440',
      :to_zip_code   => '45458',
      :weight_oz     => '1.8',
      :ship_date     => Date.today.strftime('%Y-%m-%d'),
      :package_type  => 'Package',
      :service_type  => 'US-FC',
      :cod_value     => 10.00,
      :add_ons       => {
        :add_on => [
          { :type => 'US-A-COD' },
          { :type => 'US-A-DC' }
        ]
      }
    }
 ...

mattsears avatar Sep 14 '12 11:09 mattsears