wmls 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/wmls.rb +22 -15
- metadata +1 -1
data/lib/wmls.rb
CHANGED
@@ -62,10 +62,11 @@ END
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# call WMLS_AddToStore with the given template
|
65
|
-
def add_to_store(template, optionsIn=nil)
|
65
|
+
def add_to_store(template, optionsIn=nil, headers={})
|
66
66
|
wmlTypeIn = extract_type(template)
|
67
67
|
queryIn = escape_xml(template)
|
68
68
|
soap_action = 'http://www.witsml.org/action/120/Store.WMLS_AddToStore'
|
69
|
+
headers['SOAPAction'] = soap_action
|
69
70
|
envelope_middle = <<END
|
70
71
|
<ns0:WMLS_AddToStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
71
72
|
<WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
|
@@ -74,14 +75,15 @@ END
|
|
74
75
|
<CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
|
75
76
|
</ns0:WMLS_AddToStore>
|
76
77
|
END
|
77
|
-
return send envelope_middle,
|
78
|
+
return send envelope_middle, headers
|
78
79
|
end
|
79
80
|
|
80
81
|
# call WMLS_DeleteStore with the given template
|
81
|
-
def delete_from_store(template, optionsIn = nil)
|
82
|
+
def delete_from_store(template, optionsIn = nil, headers={})
|
82
83
|
wmlTypeIn = extract_type(template)
|
83
84
|
queryIn = escape_xml(template)
|
84
85
|
soap_action = 'http://www.witsml.org/action/120/Store.WMLS_DeleteFromStore'
|
86
|
+
headers['SOAPAction'] = soap_action
|
85
87
|
envelope_middle = <<END
|
86
88
|
<ns0:WMLS_DeleteFromStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
87
89
|
<WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
|
@@ -90,14 +92,15 @@ END
|
|
90
92
|
<CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
|
91
93
|
</ns0:WMLS_DeleteFromStore>
|
92
94
|
END
|
93
|
-
return send envelope_middle,
|
95
|
+
return send envelope_middle, headers
|
94
96
|
end
|
95
97
|
|
96
98
|
# call WMLS_UpdateInStore with the given template
|
97
|
-
def update_in_store(template, optionsIn=nil)
|
99
|
+
def update_in_store(template, optionsIn=nil, headers={})
|
98
100
|
wmlTypeIn = extract_type(template)
|
99
101
|
queryIn = escape_xml(template)
|
100
102
|
soap_action = 'http://www.witsml.org/action/120/Store.WMLS_UpdateInStore'
|
103
|
+
headers['SOAPAction'] = soap_action
|
101
104
|
envelope_middle = <<END
|
102
105
|
<ns0:WMLS_UpdateInStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
103
106
|
<WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
|
@@ -106,14 +109,15 @@ END
|
|
106
109
|
<CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
|
107
110
|
</ns0:WMLS_UpdateInStore>
|
108
111
|
END
|
109
|
-
return send envelope_middle,
|
112
|
+
return send envelope_middle, headers
|
110
113
|
end
|
111
114
|
|
112
115
|
# call WMLS_GetFromStore with the given template
|
113
|
-
def get_from_store(template, optionsIn=nil)
|
116
|
+
def get_from_store(template, optionsIn=nil, headers={})
|
114
117
|
wmlTypeIn = extract_type(template)
|
115
118
|
queryIn = escape_xml(template)
|
116
119
|
soap_action = 'http://www.witsml.org/action/120/Store.WMLS_GetFromStore'
|
120
|
+
headers['SOAPAction'] = soap_action
|
117
121
|
envelope_middle = <<END
|
118
122
|
<ns0:WMLS_GetFromStore SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
119
123
|
<WMLtypeIn>#{wmlTypeIn}</WMLtypeIn>
|
@@ -122,22 +126,24 @@ END
|
|
122
126
|
<CapabilitiesIn>#{@capabilitiesIn}</CapabilitiesIn>
|
123
127
|
</ns0:WMLS_GetFromStore>
|
124
128
|
END
|
125
|
-
return send envelope_middle,
|
129
|
+
return send envelope_middle, headers
|
126
130
|
end
|
127
131
|
|
128
|
-
|
132
|
+
# call WMLS_GetCap with the specified optionsIn.
|
133
|
+
def get_cap(optionsIn=nil, headers=nil)
|
129
134
|
soap_action = 'http://www.witsml.org/action/120/Store.WMLS_GetCap'
|
135
|
+
headers['SOAPAction'] = soap_action
|
130
136
|
envelope_middle = <<END
|
131
137
|
<ns0:WMLS_GetCap SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
132
138
|
<OptionsIn>#{optionsIn || @optionsIn}</OptionsIn>
|
133
139
|
</ns0:WMLS_GetCap>
|
134
140
|
END
|
135
|
-
return send envelope_middle,
|
141
|
+
return send envelope_middle, headers
|
136
142
|
end
|
137
143
|
|
138
144
|
private
|
139
145
|
|
140
|
-
# Replace special xml
|
146
|
+
# Replace special xml characters '&' and '<'
|
141
147
|
def escape_xml(xml_in)
|
142
148
|
return xml_in.gsub(/&/,'&').gsub(/</,'<')
|
143
149
|
end
|
@@ -170,7 +176,7 @@ END
|
|
170
176
|
end
|
171
177
|
|
172
178
|
|
173
|
-
def post(io, url, user, pass,
|
179
|
+
def post(io, url, user, pass, headers)
|
174
180
|
url = URI.parse(url) if url.is_a? String
|
175
181
|
io = StringIO.new(io) if io.is_a? String
|
176
182
|
|
@@ -179,7 +185,8 @@ END
|
|
179
185
|
req.body_stream = io
|
180
186
|
|
181
187
|
#soap 1.1:
|
182
|
-
req.add_field('SOAPAction', soap_action)
|
188
|
+
#req.add_field('SOAPAction', soap_action)
|
189
|
+
headers.each_pair {|header, value| req.add_field(header, value)}
|
183
190
|
req.content_type = 'text/xml'
|
184
191
|
|
185
192
|
#soap 1.2 would replace the above with:
|
@@ -203,9 +210,9 @@ END
|
|
203
210
|
end
|
204
211
|
|
205
212
|
|
206
|
-
def send(envelope_middle,
|
213
|
+
def send(envelope_middle, headers)
|
207
214
|
envelope = @envelope_begin + envelope_middle + @envelope_end
|
208
|
-
response = post(envelope, @url, @user_name, @password,
|
215
|
+
response = post(envelope, @url, @user_name, @password, headers)
|
209
216
|
status, supp_msg, witsml = extract_response(response.body)
|
210
217
|
end
|
211
218
|
|