stamps
stamps copied to clipboard
The property 'address' is not defined for this Trash
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&uid=2799981&cty=swsim&
ctk=AAuJ3tJa7M5ALfsNktPX99CJOoM=&iid=6LKmNRnJxEyDQfY5lUwNVw==
&rsid=0&eac=0&eacx=0&rrsid=0&raid=0&resellerid=0
&pexp=0&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:in
each_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:in
new'
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:in
each_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:in
new'
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:in
method_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:in
start'
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:in
require'
from script/rails:6:in `
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?
Have you tried setting the endpoint to v12? Like this:
config.endpoint = "https://swsim.testing.stamps.com/swsim/swsimv12.asmx"
(Within the configure block)
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?
Can you post your config (omit sensitive values)?
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.
From what I understand, the error also occurs with v12 of the wsdl?
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.
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'.
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
If I comment out the tracking_number = true, here is the error I get:
what error ^^ ?
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
yes, same thing for me as well.
When I comment out the "Rate" attribute, I get an error complaining about the "From" field.
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.
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).
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
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.
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
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.
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
Nice, indeed it looks like it is working. What did you do to get around the "The property 'address' is not defined" error?
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]
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.
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.
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?
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.
I see. Thanks for your help with this.
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.
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' }
]
}
}
...