Sha256: 5048880c35c92bf50a952e9cc3c205433b7e438bc3d62ba0fb6a7f5a8bc9e154
Contents?: true
Size: 1.88 KB
Versions: 6
Compression:
Stored size: 1.88 KB
Contents
require 'net/http' require 'uri' require 'rexml/document' class StateWTTX def update_statuswttx(imsi, imei) doc = REXML::Document.new #doc.context[:attribute_quote] = :quote # <-- Set double-quote as the attribute value delimiter root = doc.add_element('row') attr1 = root.add_element('key') attr1.add_attribute('code', 'imsi') attr1.add_attribute('value', imsi) attr2 = root.add_element('field') attr2.add_attribute('code', 'imei') attr2.add_attribute('value', imei) attr3 = root.add_element('field') attr3.add_attribute('code', 'status') attr3.add_attribute('value', 'TRUE') xmlout = "" doc.write xmlout p xmlout url_string = "http://172.24.220.77:8080/custrefdata/wttx/_update" xml_string = xmlout uri = URI.parse url_string request = Net::HTTP::Post.new uri.path p request.body = xml_string request.content_type = 'application/xml' p response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request } p response.body end def getrest_cps(imsi) url = "http://172.24.220.77:8080/custrefdata/wttx/_query?imsi=#{imsi}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) response = http.request(Net::HTTP::Get.new(uri.request_uri)) p content = response.body p result_code = response.to_s.include?("OK") #Rails.logger = Logger.new(STDOUT) #logger.info "WTTX service getrestCPS result code: #{response.to_s}" #logger.info "WTTX service getrestCPS soap body: #{content.to_s}" if !result_code "false" else reg_imsi = /<field code=\"imsi\" value=\"([0-9]{10,15})\"/ reg_imei = /<field code=\"imei\" value=\"([0-9]{10,17})\"/ m1 = reg_imsi.match(content) m2 = reg_imei.match(content) imsi = m1[1] imei = m2[1] res = result_code.to_s + " " + imsi + " " + imei p res res end end end
Version data entries
6 entries across 6 versions & 1 rubygems