view · edit · sidebar · attach · print · history

Using Ruby::Savon

<< RubyXL | Index | Spreadsheet >>

 https://github.com/rubiii/savon

My first Ruby Software:

#!/usr/bin/ruby

require 'rubygems'
require 'savon'

client = Savon::Client.new do | wsdl |
  wsdl.document = "https://index.ws.e-mediat.net/Swissindex/NonPharma/ws_NonPharma_V101.asmx?WSDL"
end
p client.wsdl.soap_actions
p client.wsdl.namespace
p client.wsdl.endpoint

this will print out the commands you can use

 [:get_by_descr, :download_all, :download_by_date, :get_by_gtin, :get_by_pharmacode]

or

this will output the XML message to the terminal


#!/usr/bin/ruby

require 'rubygems'
require 'savon'

client = Savon::Client.new do | wsdl, http |
#  wsdl.endpoint = "https://index.ws.e-mediat.net/Swissindex/NonPharma/ws_NonPharma_V101.asmx"
#  wsdl.namespace = "http://swissindex.e-mediat.net/SwissindexNonPharma_out_V101"
  wsdl.document = "https://index.ws.e-mediat.net/Swissindex/NonPharma/ws_NonPharma_V101.asmx?WSDL"
#  http.headers["SOAPAction"] = '"http://swissindex.e-mediat.net/SwissindexNonPharma_out_V101/DownloadAll"'
end

response = client.request :get_by_pharmacode do
  soap.xml = '<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <pharmacode xmlns="http://swissindex.e-mediat.net/SwissindexNonPharma_out_V101">'+ARGV[0]+'</pharmacode>
        <lang xmlns="http://swissindex.e-mediat.net/SwissindexNonPharma_out_V101">DE</lang>
    </soap:Body>
  </soap:Envelope>'
end

p response
view · edit · sidebar · attach · print · history
Page last modified on April 06, 2012, at 05:11 PM