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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/wmls.rb', line 42

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

  @optionsIn = ''
  @capabilitiesIn = ''
  @timeout = 60

  @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
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

Instance Method Details

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

call WMLS_AddToStore with the given template



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/wmls.rb', line 65

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



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/wmls.rb', line 82

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.



133
134
135
136
137
138
139
140
141
142
# File 'lib/wmls.rb', line 133

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



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/wmls.rb', line 116

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



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/wmls.rb', line 99

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