Note that there are some explanatory texts on larger screens.

plurals
  1. POSOAP request works on PHP but not working on Ruby (gem: Savon2)
    text
    copied!<p>I am trying to perform SOAP request called DoProduct. This method is updating specific product. I looked through WSDL (<a href="http://api.istore.pl/#op.idp182160" rel="nofollow">http://api.istore.pl/#op.idp182160</a>) and found out that I need one Product object and session key. </p> <p>Everything working perfectly with PHP:</p> <pre><code> $product = $soap-&gt;__soapCall("getProduct", array("sessionId" =&gt; $key, "productId" =&gt; $id)); $result = $soap-&gt;__soapCall("doProduct", array("sessionId" =&gt; $key, "product" =&gt; $product)); </code></pre> <p>I tried the same approach with Ruby (first get product, then send it back):</p> <pre><code> product = client.call(:get_product, message: {:session_id =&gt; session_key, :product_id =&gt; id}) response = @@client.call(:do_product, message: {:session_id =&gt; session_key, :product =&gt; product.hash[:envelope][:body][:get_product_response][:return]}) </code></pre> <p>Ruby version is not working. I am receiving error that one parameter was not send (of course that parameter is there, I've checked hash from first response):</p> <pre><code> HTTPI POST request to api.istore.pl (net_http) SOAP response (status 500) &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;S OAP-ENV:Body&gt;&lt;SOAP-ENV:Fault&gt;&lt;faultcode&gt;ERR_EMPTY_PRODUCT_TAX&lt;/faultcode&gt;&lt;faults tring&gt;&lt;/faultstring&gt;&lt;/SOAP-ENV:Fault&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt; Savon::SOAPFault: (ERR_EMPTY_PRODUCT_TAX) from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/savon-2.1.0/lib/savon/response.rb:70:in `raise_soap_and_http_errors!' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/savon-2.1.0/lib/savon/response.rb:13:in `initialize' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/savon-2.1.0/lib/savon/operation.rb:52:in `new' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/savon-2.1.0/lib/savon/operation.rb:52:in `call' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/savon-2.1.0/lib/savon/client.rb:38:in `call' from C:/Users/Arti/Documents/adgally/v1/app/models/istore.rb:45:in `update_product' from (irb):60 from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start' from F:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `&lt;top (required)&gt;' from script/rails:6:in `require' from script/rails:6:in `&lt;main&gt;' </code></pre> <p>@EDIT PHP response (vardump):</p> <pre><code>object(stdClass)[2] public 'Id' =&gt; int 18028717 public 'PropertiesIds' =&gt; array (size=0) empty public 'ImagesIds' =&gt; array (size=1) 0 =&gt; int 22573396 public 'Currency' =&gt; object(stdClass)[3] public 'Id' =&gt; int 1 public 'Symbol' =&gt; string 'PLN' (length=3) public 'Round' =&gt; boolean false public 'Active' =&gt; boolean true public 'Rate' =&gt; float 1 public 'Tax' =&gt; object(stdClass)[4] public 'Id' =&gt; int 23 public 'Name' =&gt; string '23%' (length=3) public 'Rate' =&gt; float 23 public 'Symbol' =&gt; string ' ' (length=1) public 'Promotion' =&gt; boolean false public 'Wholesale' =&gt; boolean false public 'New' =&gt; boolean false public 'DeliveryTimeLength' =&gt; int 0 public 'DeliveryTimeLengthPeriod' =&gt; string 'D' (length=1) public 'Producer' =&gt; null public 'PKWiU' =&gt; null public 'Active' =&gt; boolean true public 'Netto' =&gt; float 11.38 public 'Brutto' =&gt; float 14 public 'PromotionNetto' =&gt; float 0 public 'PromotionBrutto' =&gt; float 0 public 'WholesaleNetto' =&gt; float 0 public 'WholesaleBrutto' =&gt; float 0 public 'FirstPage' =&gt; int 0 public 'Sequence' =&gt; int 18028717 public 'Unit' =&gt; object(stdClass)[5] public 'Id' =&gt; int 1 public 'Symbol' =&gt; string 'szt.' (length=4) public 'PostSize' =&gt; string 'A' (length=1) public 'SortProperty' =&gt; string 'N' (length=1) public 'MainCategory' =&gt; object(stdClass)[6] public 'Id' =&gt; int 34 public 'Name' =&gt; string 'Odzież, Obuwie, Dodatki' (length=24) public 'Names' =&gt; array (size=1) 0 =&gt; object(stdClass)[7] public 'Symbol' =&gt; string 'pl' (length=2) public 'Name' =&gt; string 'Bluzka testowa 2' (length=16) public 'Description' =&gt; array (size=1) 0 =&gt; object(stdClass)[8] public 'Symbol' =&gt; string 'pl' (length=2) public 'Description' =&gt; string 'asdsad' (length=6) public 'HTMLDescription' =&gt; array (size=1) 0 =&gt; object(stdClass)[9] public 'Symbol' =&gt; string 'pl' (length=2) public 'Description' =&gt; string 'asdasdas' (length=8) public 'MetaKeywords' =&gt; array (size=1) 0 =&gt; object(stdClass)[10] public 'Symbol' =&gt; string 'pl' (length=2) public 'Description' =&gt; string 'bluzka, jesień, fajna' (length=22) public 'CategoriesIds' =&gt; array (size=1) 0 =&gt; int 1695922 public 'BindingProducts' =&gt; array (size=0) empty public 'Availability' =&gt; string 'A' (length=1) public 'Quality' =&gt; string 'N' (length=1) public 'Variants' =&gt; array (size=1) 0 =&gt; object(stdClass)[11] public 'ShopProductPropertyValueIds' =&gt; array (size=0) ... public 'Quantity' =&gt; float 1 public 'WarehouseId' =&gt; int 20666112 public 'Available' =&gt; boolean true public 'Weight' =&gt; float 0 public 'Blocked' =&gt; boolean false public 'HideExternalOpinions' =&gt; boolean false public 'Width' =&gt; int 0 public 'Height' =&gt; int 0 public 'Deep' =&gt; int 0 public 'InpostEnabled' =&gt; boolean false public 'Available' =&gt; boolean true public 'Ean' =&gt; null </code></pre> <p>Ruby Savon response.to_hash object (sorry for formatting, but I dont have any idea how to format it from console properly): <a href="http://pastie.org/7065887" rel="nofollow">http://pastie.org/7065887</a></p> <p>Additionaly ruby response.to_json (formatting is better): </p> <pre><code>{ "get_product_response":{ "return":{ "id":"18028717", "properties_ids":{ "@soap_enc:array_type":"xsd:int[0]", "@xsi:type":"ns1:ArrayOfint" }, "images_ids":{ "item":"22573396", "@soap_enc:array_type":"xsd:int[1]", "@xsi:type":"ns1:ArrayOfint" }, "currency":{ "id":"1", "symbol":"PLN", "round":false, "active":true, "rate":"1", "@xsi:type":"ns1:Currency" }, "tax":{ "id":"23", "name":"23%", "rate":"23", "@xsi:type":"ns1:Tax" }, "symbol":{ "@xsi:type":"xsd:string" }, "promotion":false, "wholesale":false, "new":false, "delivery_time_length":"0", "delivery_time_length_period":"D", "producer":null, "pk_wi_u":null, "active":true, "netto":"11.38", "brutto":"14", "promotion_netto":"0", "promotion_brutto":"0", "wholesale_netto":"0", "wholesale_brutto":"0", "first_page":"0", "sequence":"18028717", "unit":{ "id":"1", "symbol":"szt.", "@xsi:type":"ns1:Unit" }, "post_size":"A", "sort_property":"N", "main_category":{ "id":"34", "name":"Odzieu017c, Obuwie, Dodatki", "@xsi:type":"ns1:MainCategory" }, "names":{ "item":{ "symbol":"pl", "name":"Bluzka testowa 2", "@xsi:type":"ns1:TranslationName" }, "@soap_enc:array_type":"ns1:TranslationName[1]", "@xsi:type":"ns1:ArrayOfTranslationName" }, "description":{ "item":{ "symbol":"pl", "description":"asdsad", "@xsi:type":"ns1:TranslationDescription" }, "@soap_enc:array_type":"ns1:TranslationDescription[1]", "@xsi:type":"ns1:ArrayOfTranslationDescription" }, "html_description":{ "item":{ "symbol":"pl", "description":"asdasdas", "@xsi:type":"ns1:TranslationDescription" }, "@soap_enc:array_type":"ns1:TranslationDescription[1]", "@xsi:type":"ns1:ArrayOfTranslationDescription" }, "meta_keywords":{ "item":{ "symbol":"pl", "description":"bluzka, jesieu0144, fajna", "@xsi:type":"ns1:TranslationDescription" }, "@soap_enc:array_type":"ns1:TranslationDescription[1]", "@xsi:type":"ns1:ArrayOfTranslationDescription" }, "categories_ids":{ "item":"1695922", "@soap_enc:array_type":"xsd:int[1]", "@xsi:type":"ns1:ArrayOfint" }, "binding_products":{ "@soap_enc:array_type":"xsd:int[0]", "@xsi:type":"ns1:ArrayOfint" }, "availability":"A", "quality":"N", "variants":{ "item":{ "shop_product_property_value_ids":{ "@soap_enc:array_type":"xsd:int[0]", "@xsi:type":"ns1:ArrayOfint" }, "quantity":"1", "warehouse_id":"20666112", "available":true, "@xsi:type":"ns1:ProductVariant" }, "@soap_enc:array_type":"ns1:ProductVariant[1]", "@xsi:type":"ns1:ArrayOfProductVariant" }, "weight":"0", "blocked":false, "hide_external_opinions":false, "width":"0", "height":"0", "deep":"0", "inpost_enabled":false, "available":true, "ean":null, "@xsi:type":"ns1:Product" } } } </code></pre> <p>Does any one could give me any hint?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload