Ruby on rails SOAP请求在PHP上工作,但在Ruby上不工作(gem:Savon2)

Ruby on rails SOAP请求在PHP上工作,但在Ruby上不工作(gem:Savon2),ruby-on-rails,ruby,soap,savon,Ruby On Rails,Ruby,Soap,Savon,我正在尝试执行名为DoProduct的SOAP请求。此方法正在更新特定产品。我浏览了WSDL(),发现我需要一个产品对象和会话密钥 一切都可以完美地使用PHP: $product = $soap->__soapCall("getProduct", array("sessionId" => $key, "productId" => $id)); $result = $soap->__soapCall("doProduct", array("sessionId

我正在尝试执行名为DoProduct的SOAP请求。此方法正在更新特定产品。我浏览了WSDL(),发现我需要一个产品对象和会话密钥

一切都可以完美地使用PHP:

    $product = $soap->__soapCall("getProduct", array("sessionId" => $key, "productId" => $id));
    $result = $soap->__soapCall("doProduct", array("sessionId" => $key, "product" => $product));
我在Ruby上尝试了同样的方法(首先获取产品,然后将其发送回):

Ruby版本不工作。我收到一个参数未发送的错误(当然,该参数存在,我已检查了第一个响应中的哈希):

Ruby Savon response.to_散列对象(很抱歉格式化,但我不知道如何从控制台正确格式化它):

另外,ruby response.to_json(格式更好):


有人能给我任何提示吗?

根据SOAP响应,您实际上缺少了SOAP服务所期望的一个参数

我注意到在PHP版本中,您只发送整个product对象,但在Ruby版本中,您正在挖掘响应哈希


您可以检查两个版本中的“产品”并在此处发布响应吗?

这与错误
ERR\u EMPTY\u product\u TAX
调试无关?像控制器方法中的
提升参数。inspect
这样疯狂的东西应该会在soap响应中返回您的请求参数对不起,但是仅仅获取该散列并重用它可能不起作用。@rubiii,那么我应该怎么做呢?构建自己的XML文档并将其传递给call method?@Arti是的,我将从响应中获取参数,并根据您需要的值构造新的请求消息。不过你提出了一个很好的观点。我对我的问题补充了回答。非常感谢你的帮助。
    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]})
    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>'
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
{
   "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"
      }
   }
}