Sha256: 66fe297fa6c6abcc6a4bf42ee4cf108946e4576d673b041cc4fef975dc3e1ce6

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module Patentscope

  class WebserviceSoapStripper

    def strip_envelope(response, operation)
      case operation
      when :getAvailableDocuments
        result_tag = 'getAvailableDocumentsResponse'
      when :getDocumentContent
        result_tag = 'getDocumentContentResponse'
      when :getDocumentOcrContent
        result_tag = 'getDocumentOcrContentResponse'
      when :getIASR
        result_tag = 'getIASRResponse'
      when :getDocumentTableOfContents
        result_tag = 'getDocumentTableOfContentsResponse'
      when :getDocumentContentPage
        result_tag = 'getDocumentContentPageResponse'
      end

      doc = Nokogiri::XML(response)
      stripped_response = doc.xpath("//iasr:#{result_tag}", 'iasr' => "http://www.wipo.org/wsdl/ps").children

      # add back the XML declaration to the XML with a namespace
      stripped_response_with_declaration = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
        xml.send(result_tag, "xmlns" => "http://www.wipo.org/wsdl/ps") do
          xml.parent << stripped_response
        end
      end.to_xml

      stripped_response_with_declaration
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
patentscope-0.0.5 lib/patentscope/webservice_soap_stripper.rb
patentscope-0.0.4 lib/patentscope/webservice_soap_stripper.rb