Skip to content

Commit f60f4ac

Browse files
committed
more adapted headers
1 parent c21df0d commit f60f4ac

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/soap/request.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ defmodule Soap.Request do
1616

1717
def call(wsdl, operation, {soap_headers, params}, request_headers, opts, flags) do
1818
url = get_url(wsdl, force_https?())
19-
request_headers = Headers.build(wsdl, operation, request_headers)
2019
body = Params.build_body(wsdl, operation, params, soap_headers)
20+
request_headers = Headers.build(wsdl, operation, request_headers, body)
2121

2222
if flags[:debug] do
2323
Logger.debug(%{log_id: "soap-call-debug", url: url, body: body, request_headers: request_headers, opts: opts})

lib/soap/request/headers.ex

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,28 @@ defmodule Soap.Request.Headers do
1515
"1.2" => "application/soap+xml; charset=utf-8",
1616
}
1717

18-
@spec build(map(), String.t(), list()) :: list()
19-
def build(wsdl, operation, custom_headers) do
18+
@spec build(map(), String.t(), list(), String.t()) :: list()
19+
def build(wsdl, operation, custom_headers, body) do
2020
wsdl
2121
|> extract_soap_action_by_operation(operation)
22-
|> extract_headers(custom_headers, wsdl)
22+
|> extract_headers(custom_headers, wsdl, body)
2323
end
2424

2525
@spec extract_soap_action_by_operation(map(), String.t()) :: String.t()
2626
defp extract_soap_action_by_operation(wsdl, operation) do
2727
Enum.find(wsdl[:operations], fn x -> x[:name] == operation end)[:soap_action]
2828
end
2929

30-
@spec extract_headers(String.t(), list(), map()) :: list()
31-
defp extract_headers(soap_action, [], wsdl), do: base_headers(soap_action, wsdl)
32-
defp extract_headers(_, custom_headers, _), do: custom_headers
30+
@spec extract_headers(String.t(), list(), map(), String.t()) :: list()
31+
defp extract_headers(soap_action, [], wsdl, body), do: base_headers(soap_action, wsdl, body)
32+
defp extract_headers(_, custom_headers, _, _), do: custom_headers
3333

34-
@spec base_headers(String.t(), map()) :: list()
35-
defp base_headers(soap_action, wsdl) do
34+
@spec base_headers(String.t(), map(), String.t()) :: list()
35+
defp base_headers(soap_action, wsdl, body) do
3636
uri = URI.parse(wsdl[:endpoint])
3737
[
38-
{"Content-Type", Map.get(@content_types, wsdl[:soap_version])},
38+
{"Content-Length", byte_size(body)},
39+
{"Content-Type", "application/x-www-form-urlencoded"},
3940
{"User-Agent", "strong-soap/3.4.0"},
4041
{"Accept", "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8"},
4142
{"Accept-Encoding", "none"},

0 commit comments

Comments
 (0)