0

I have this method on a web service I'm consuming, using SAVON 3 on Rails 3 web app

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:gpa="http://schemas.datacontract.org/2004/07/Gpa.Comercio.Servicos.Contracts.DTO">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:CalcularCarrinho>
         <!--Optional:-->
         <tem:carrinho>
            <!--Optional:-->
            <gpa:CEP>parameter here</gpa:CEP>
            <!--Optional:-->
            <gpa:CNPJ>parameter here</gpa:CNPJ>
            <!--Optional:-->
            <gpa:IdCampanha> parameter here </gpa:IdCampanha>
            <!--Optional:-->
            <gpa:Produtos>
               <!--Zero or more repetitions:-->
               <gpa:DadosListaProdutoCarrinhoDTO>
                  <!--Optional:-->
                  <gpa:Codigo> parameter here </gpa:Codigo>
                  <!--Optional:-->
                  <gpa:Quantidade>parameter here</gpa:Quantidade>
               </gpa:DadosListaProdutoCarrinhoDTO>
            </gpa:Produtos>
         </tem:carrinho>
      </tem:CalcularCarrinho>
   </soapenv:Body>
</soapenv:Envelope>

How should I make a call to this method, considering that the "Produtos" parameter is an array? I tried:

client.call(:calcular_carrinho){message(id_campanha: 2543, cnpj: '93.528.261/0001-60', cep: '04080013', produtos: ['379457', 1])}

P.S: I made tests with soapUI and the service is working...

OtavioLipari
  • 85
  • 1
  • 8

2 Answers2

0

I solve this question!

The call to this method:

client = Savon.client(wsdl: "webserviceadress?wsdl")  

message = { :carrinho => {cep: '04080013',cnpj: '93.528.261/0001-60', id_campanha: 2543, :produtos => {:dados_lista_produto_carrinho_dto => {codigo: '379457', quantidade: 1}}}}

calc_carrinho = client.call(:method_name, message: message)
OtavioLipari
  • 85
  • 1
  • 8
0

According to your question statement I assume you want to use version 3 of gem Savon. The syntax interface for Savon 3 is different from that used in 2.x.

You need to create a Savon-Object first and then create an operation with the corresponding Service/Port data.

client         = Savon.new('http://link_to_your_wsdl_here')
operation      = client.operation('ServiceName', 'Port', 'custom_action_here')
operation.body = { message:  {} }

You can fire up the request by operation.call then.

Since the documentation for Savon 3 is sparse due to its development state I don't know how reliable the above code is. I would be happy seeing someone correcting me if it is not the right way.