@@ -21,7 +21,7 @@ defmodule Soap.Request.Params do
21
21
Returns XML-like string.
22
22
"""
23
23
24
- @ spec build_body ( wsdl :: map ( ) , operation :: String . t ( ) | atom ( ) , params :: map ( ) | tuple ( ) , headers :: map ( ) ) ::
24
+ @ spec build_body ( wsdl :: map ( ) , operation :: String . t ( ) | atom ( ) , params :: map ( ) | tuple ( ) , headers :: map ( ) | tuple ( ) ) ::
25
25
String . t ( )
26
26
def build_body ( wsdl , operation , params , headers ) do
27
27
with { :ok , body } <- build_soap_body ( wsdl , operation , params ) ,
@@ -130,6 +130,15 @@ defmodule Soap.Request.Params do
130
130
end
131
131
end
132
132
133
+ #if first parameter is a map, bypass header wrapper and use header as is to handle multiple headers
134
+ defp build_soap_header ( _wsdl , _operation , [ { _tag , % { } = _attrs , _nested } | _ ] = headers ) do
135
+ body =
136
+ headers
137
+ |> add_header_tag_wrapper
138
+
139
+ { :ok , body }
140
+ end
141
+
133
142
defp build_soap_header ( wsdl , operation , headers ) do
134
143
case headers |> construct_xml_request_header do
135
144
{ :error , messages } ->
@@ -181,6 +190,10 @@ defmodule Soap.Request.Params do
181
190
end
182
191
183
192
@ spec construct_xml_request_header ( params :: tuple ( ) ) :: tuple ( )
193
+ defp construct_xml_request_header ( { tag , attrs , nested } ) do
194
+ [ { to_string ( tag ) , attrs , construct_xml_request_header ( nested ) } ]
195
+ end
196
+
184
197
defp construct_xml_request_header ( params ) when is_tuple ( params ) do
185
198
params
186
199
|> Tuple . to_list ( )
@@ -190,8 +203,8 @@ defmodule Soap.Request.Params do
190
203
end
191
204
192
205
@ spec construct_xml_request_header ( params :: String . t ( ) | atom ( ) | number ( ) ) :: String . t ( )
193
- defp construct_xml_request_header ( params ) when is_atom ( params ) or is_number ( params ) , do: params |> to_string
194
- defp construct_xml_request_header ( params ) when is_binary ( params ) , do: params
206
+ defp construct_xml_request_header ( params ) when is_atom ( params ) , do: params |> to_string ( )
207
+ defp construct_xml_request_header ( params ) when is_binary ( params ) or is_number ( params ) , do: params
195
208
196
209
@ spec insert_tag_parameters ( params :: list ( ) ) :: list ( )
197
210
defp insert_tag_parameters ( params ) when is_list ( params ) , do: params |> List . insert_at ( 1 , nil )
0 commit comments