2012-10-20 44 views
2

我試圖查詢貨幣的netsuite api。以下SOAP請求適用於SOAP UI客戶端。但是我很難與Rubyy Savon Gem 0.9.7版本一起工作。香皂屬性

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:messages_2012_2.platform.webservices.netsuite.com" xmlns:urn1="urn:core_2012_2.platform.webservices.netsuite.com"> 
    <soapenv:Header> 
     <urn:passport> 
     <urn1:email>[email protected]</urn1:email> 
     <urn1:password>xxx</urn1:password> 
     <urn1:account>xxx</urn1:account> 
     </urn:passport> 
    </soapenv:Header> 
    <soapenv:Body> 
     <urn:getAll> 
     <urn:record recordType="currency"/> 
     </urn:getAll> 
    </soapenv:Body> 
</soapenv:Envelope> 

基本上我不能在urn:record元素上設置屬性。以下不起作用:

response = client.request :urn, :get_all do 
    soap.body = { "urn:record" => { :attributes! => { "recordType" => "currency" } } } 
end 

請指教。

回答

2

http://savonrb.com所述,attributes!散列中的密鑰必須與XML標記匹配。你想寫這樣的東西:

 
response = client.request :urn, :get_all do 
    soap.body = {'urn:record'=>'', 
       :attributes!=>{'urn:record'=>{'recordType'=>'currency'}} 
       } 
end 

請讓我們知道這是否爲你解決它。

+1

謝謝Steffen,它似乎挺身而出。但它現在失敗了,因爲我認爲它期望「soapenv:」作爲標題和正文標記的前綴而不是「env:」。你知道如何得到這個前綴嗎? –

+0

明白了,它的'soap.env_namespace =「soapenv」'但沒有幫助,因爲它沒有發送肥皂頭。 –

+0

終於用'soap.header = passport_header'設置了。其中passport_header是{ '甕:護照'=> { '金塔:電子郵件'=> NETSUITE_EMAIL, '甕:密碼'=> NETSUITE_PWD, '甕:帳戶'=> NETSUITE_ACCT }} –

1

仔細檢查原始肥皂請求。 :get_all可能需要「getAll」讓savon逐字地帶你;它可能會將其更改爲GetAll

+0

缺省值是Savon將':get_all'轉換爲'getAll'。請參閱http://savonrb.com上的文檔 –

0

在薩翁您可以將新versioin:在本地上下文操作標籤屬性:

@interaction_client.call(:retrieve_interaction, message: message_hash, :attributes => { 'attachmentInfo' => include_attachments.to_s }) 

在這種情況下,attachmentInfo屬性將被放置到與操作鏈接的主操作的標籤,在這個例子就是ns:RetrieveInteractionRequest標籤。

請注意,該語法不包含感嘆號。