Class: Wmls

Inherits:
Object
  • Object
show all
Defined in:
lib/wmls.rb

Overview

A WITSML client library. Construct an instance with the URL of the WITSML service, and credentials. Then call the WMLS methods, passing a WITSML query template to each method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, user_name, password) ⇒ Wmls

Construct a new Wmls instance. url The URL of the remote WMLS service user_name, password Credentials for the remote service



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/wmls.rb', line 45

def initialize (url, user_name, password)
  @url = url
  @user_name = user_name
  @password = password

  @optionsIn = ''
  @capabilitiesIn = ''
  @timeout = 60
  @verbose = false

  @envelope_begin = <<END
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:ns0="http://www.witsml.org/message/120">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
END

  @envelope_end = <<END
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
END
  # Permit parsing really large WITSML files (1GB)
  REXML::Document::entity_expansion_text_limit=1024*1024*1024


end

Instance Attribute Details

#timeoutObject

The HTTP timeout in seconds (default 60)



36
37
38
# File 'lib/wmls.rb', line 36

def timeout
  @timeout
end

#verboseObject

Shouls we run verbosely



39
40
41
# File 'lib/wmls.rb', line 39

def verbose
  @verbose
end

Instance Method Details

#add_to_store(template, optionsIn = nil, headers = {}) ⇒ Object

call WMLS_AddToStore with the given template



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/wmls.rb', line 73

def add_to_store(template, optionsIn=nil, headers={})
  wmlTypeIn = extract_type(template)
  queryIn = escape_xml(template)
  soap_action = 'http://www.witsml.org/action/120/Store.WMLS_AddToStore'
  headers['SOAPAction'] = soap_action
  envelope_middle = <<END
      <ns0:WMLS_AddToStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
          <XMLin>#{queryIn}</XMLin>
          <OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
          <CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
      </ns0:WMLS_AddToStore>
END
  return send envelope_middle, headers
end

#delete_from_store(template, optionsIn = nil, headers = {}) ⇒ Object

call WMLS_DeleteStore with the given template



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/wmls.rb', line 90

def delete_from_store(template, optionsIn = nil, headers={})
  wmlTypeIn = extract_type(template)
  queryIn = escape_xml(template)
  soap_action = 'http://www.witsml.org/action/120/Store.WMLS_DeleteFromStore'
  headers['SOAPAction'] = soap_action
  envelope_middle = <<END
      <ns0:WMLS_DeleteFromStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
          <QueryIn>#{queryIn}</QueryIn>
          <OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
          <CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
      </ns0:WMLS_DeleteFromStore>
END
  return send envelope_middle, headers
end

#get_cap(optionsIn = nil, headers = {}) ⇒ Object

call WMLS_GetCap with the specified optionsIn.



141
142
143
144
145
146
147
148
149
150
# File 'lib/wmls.rb', line 141

def get_cap(optionsIn=nil, headers={})
  soap_action = 'http://www.witsml.org/action/120/Store.WMLS_GetCap'
  headers['SOAPAction'] = soap_action
  envelope_middle = <<END
      <ns0:WMLS_GetCap SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
      </ns0:WMLS_GetCap>
END
  return send envelope_middle, headers 
end

#get_from_store(template, optionsIn = nil, headers = {}) ⇒ Object

call WMLS_GetFromStore with the given template



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/wmls.rb', line 124

def get_from_store(template, optionsIn=nil, headers={})
  wmlTypeIn = extract_type(template)
  queryIn = escape_xml(template)
  soap_action = 'http://www.witsml.org/action/120/Store.WMLS_GetFromStore'
  headers['SOAPAction'] = soap_action
  envelope_middle = <<END
      <ns0:WMLS_GetFromStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
          <QueryIn>#{queryIn}</QueryIn>
          <OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
          <CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
      </ns0:WMLS_GetFromStore>
END
  return send envelope_middle, headers
end

#update_in_store(template, optionsIn = nil, headers = {}) ⇒ Object

call WMLS_UpdateInStore with the given template



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/wmls.rb', line 107

def update_in_store(template, optionsIn=nil, headers={})
  wmlTypeIn = extract_type(template)
  queryIn = escape_xml(template)
  soap_action = 'http://www.witsml.org/action/120/Store.WMLS_UpdateInStore'
  headers['SOAPAction'] = soap_action
  envelope_middle = <<END
      <ns0:WMLS_UpdateInStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
          <XMLin>#{queryIn}</XMLin>
          <OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
          <CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
      </ns0:WMLS_UpdateInStore>
END
  return send envelope_middle, headers
end