I am trying to perform SOAP request called DoProduct. This method is updating specific product. I looked through WSDL ( http://api.istore.pl/#op.idp182160 ) and found out that I need one Product object and session key.
Everything working perfectly with PHP:
$product = $soap->__soapCall("getProduct", array("sessionId" => $key, "productId" => $id));
$result = $soap->__soapCall("doProduct", array("sessionId" => $key, "product" => $product));
I tried the same approach with Ruby (first get product, then send it back):
product = client.call(:get_product, message: {:session_id => session_key, :product_id => id})
response = @@client.call(:do_product, message: {:session_id => session_key, :product => product.hash[:envelope][:body][:get_product_response][:return]})
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):
HTTPI POST request to api.istore.pl (net_http)
SOAP response (status 500)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><S
OAP-ENV:Body><SOAP-ENV:Fault><faultcode>ERR_EMPTY_PRODUCT_TAX</faultcode><faults
tring></faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
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 `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
@EDIT PHP response (vardump):
object(stdClass)[2]
public 'Id' => int 18028717
public 'PropertiesIds' =>
array (size=0)
empty
public 'ImagesIds' =>
array (size=1)
0 => int 22573396
public 'Currency' =>
object(stdClass)[3]
public 'Id' => int 1
public 'Symbol' => string 'PLN' (length=3)
public 'Round' => boolean false
public 'Active' => boolean true
public 'Rate' => float 1
public 'Tax' =>
object(stdClass)[4]
public 'Id' => int 23
public 'Name' => string '23%' (length=3)
public 'Rate' => float 23
public 'Symbol' => string ' ' (length=1)
public 'Promotion' => boolean false
public 'Wholesale' => boolean false
public 'New' => boolean false
public 'DeliveryTimeLength' => int 0
public 'DeliveryTimeLengthPeriod' => string 'D' (length=1)
public 'Producer' => null
public 'PKWiU' => null
public 'Active' => boolean true
public 'Netto' => float 11.38
public 'Brutto' => float 14
public 'PromotionNetto' => float 0
public 'PromotionBrutto' => float 0
public 'WholesaleNetto' => float 0
public 'WholesaleBrutto' => float 0
public 'FirstPage' => int 0
public 'Sequence' => int 18028717
public 'Unit' =>
object(stdClass)[5]
public 'Id' => int 1
public 'Symbol' => string 'szt.' (length=4)
public 'PostSize' => string 'A' (length=1)
public 'SortProperty' => string 'N' (length=1)
public 'MainCategory' =>
object(stdClass)[6]
public 'Id' => int 34
public 'Name' => string 'Odzież, Obuwie, Dodatki' (length=24)
public 'Names' =>
array (size=1)
0 =>
object(stdClass)[7]
public 'Symbol' => string 'pl' (length=2)
public 'Name' => string 'Bluzka testowa 2' (length=16)
public 'Description' =>
array (size=1)
0 =>
object(stdClass)[8]
public 'Symbol' => string 'pl' (length=2)
public 'Description' => string 'asdsad' (length=6)
public 'HTMLDescription' =>
array (size=1)
0 =>
object(stdClass)[9]
public 'Symbol' => string 'pl' (length=2)
public 'Description' => string 'asdasdas' (length=8)
public 'MetaKeywords' =>
array (size=1)
0 =>
object(stdClass)[10]
public 'Symbol' => string 'pl' (length=2)
public 'Description' => string 'bluzka, jesień, fajna' (length=22)
public 'CategoriesIds' =>
array (size=1)
0 => int 1695922
public 'BindingProducts' =>
array (size=0)
empty
public 'Availability' => string 'A' (length=1)
public 'Quality' => string 'N' (length=1)
public 'Variants' =>
array (size=1)
0 =>
object(stdClass)[11]
public 'ShopProductPropertyValueIds' =>
array (size=0)
...
public 'Quantity' => float 1
public 'WarehouseId' => int 20666112
public 'Available' => boolean true
public 'Weight' => float 0
public 'Blocked' => boolean false
public 'HideExternalOpinions' => boolean false
public 'Width' => int 0
public 'Height' => int 0
public 'Deep' => int 0
public 'InpostEnabled' => boolean false
public 'Available' => boolean true
public 'Ean' => null
Ruby Savon response.to_hash object (sorry for formatting, but I dont have any idea how to format it from console properly): http://pastie.org/7065887
Additionaly ruby response.to_json (formatting is better):
{
"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"
}
}
}
Does any one could give me any hint?
According to the SOAP response, you are in fact missing a parameter the SOAP service is expecting.
I notice with the PHP version you are just sending the entire product object, but in the Ruby version you are digging into the response hash.
Can you inspect 'product' in both versions and post the response here?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.