使用Ruby on Rails和Savon gem发送货件请求,非常具体的问题

时间:2014-02-15 22:02:03

标签: ruby-on-rails soap soap-client savon

在阅读文档几次并浏览互联网后,我决定寻求帮助。我必须发出一个SOAP请求,发送一个如下所示的复杂对象:

http://mountainstream.ms/so1.png

http://mountainstream.ms/so2.png

http://mountainstream.ms/so3.png

我尝试使用Ruby实例变量将数据保存在哈希中。它看起来像这样:

@@order[:pickupDate] = { pickupDate: '', readyTime: '08:00', closeTime: '20:00'}
@@order[:service] = { shipper: shipper, packaging: packaging }
package = [weight, length, height, width, shape, packaging, packageValue]
@@order[:packages] = package
@@order[:packageServiceOptions] = { insurance: insurance, cod: cod, description:   description, remarks: remarks }
@@order[:inpostMachines] = { senderMachine: '', recipientMachine: '', alternativeRecipientMachine: '' }
@@order[:sender] = { contact: { companyName: sender_company_name,
                                  personName: sender_name,
                                  phoneNumber: sender_phone,
                                  emailAddress: sender_email
                                },
                       address: { street: sender_street,
                                  postalCode: sender_po,
                                  city: sender_city,
                                  stateOrProvinceCode: sender_state,
                                  country: sender_country
                        }} 
@@order[:recipient] = { contact: { companyName:  rec_company_name,
                                     personName: rec_name,
                                     phoneNumber: rec_phone,
                                     emailAddress: rec_email
                                   },
                          address: { street: rec_street,
                                     postalCode: rec_po,
                                     city: rec_city,
                                     stateOrProvinceCode: rec_state,
                                     country: rec_country
                         }}

response = @@client.call(:rate_shipment, message: { shipementToEvaluate: @@order, 
apiKey: apiKey, sessionId: @@sessionId})

发送时,回复包含错误:

`<h1>CException</h1> <p>Argument 1 passed to ShipmentValidator::__construct() must be an instance of Shipment, null given, called in /api/protected/controllers/ShipServiceController.php on line 252 and defined</p>`

我试图重新排列哈希无济于事,我在这里做错了什么?

0 个答案:

没有答案