Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions include/detergent.hrl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-ifndef(DETERGENT).
-define(DETERGENT, true).

-define(DEFAULT_PREFIX, "p").
-define(DEFAULT_PREFIX, "ns1").

-record(call_opts, {url, prefix=?DEFAULT_PREFIX,
http_headers=[],
Expand All @@ -12,11 +12,11 @@
-record(wsdl, {operations, model, module}).
-record(port, {service, port, binding, address}).
-record(operation, {service, port, operation, binding, address, action}).
-record('soap:detail', {anyAttribs, choice}).
-record('soap:Fault', {anyAttribs, 'faultcode', 'faultstring', 'faultactor', 'detail'}).
-record('soap:Body', {anyAttribs, choice}).
-record('soap:Header', {anyAttribs, choice}).
-record('soap:Envelope', {anyAttribs, 'Header', 'Body', choice}).
-record('SOAP-ENV:detail', {anyAttribs, choice}).
-record('SOAP-ENV:Fault', {anyAttribs, 'faultcode', 'faultstring', 'faultactor', 'detail'}).
-record('SOAP-ENV:Body', {anyAttribs, choice}).
-record('SOAP-ENV:Header', {anyAttribs, choice}).
-record('SOAP-ENV:Envelope', {anyAttribs, 'Header', 'Body', choice}).
-record('wsdl:tExtensibilityElement', {anyAttribs, 'wsdl:required'}).
-record('wsdl:tPort', {anyAttribs, 'name', 'binding', 'documentation', choice}).
-record('wsdl:tService', {anyAttribs, 'name', 'documentation', choice, 'port'}).
Expand Down Expand Up @@ -49,13 +49,13 @@
-record('wsdl:tDocumented', {anyAttribs, 'documentation'}).
-record('wsdl:tDocumentation-any', {anyAttribs, choice}).
-record('wsdl:tDocumentation', {anyAttribs, choice}).
-record('soap:tBinding', {anyAttribs, 'wsdl:required', 'transport', 'style'}).
-record('soap:tOperation', {anyAttribs, 'wsdl:required', 'soapAction', 'style'}).
-record('soap:tBody', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle'}).
-record('soap:tFaultRes', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle'}).
-record('soap:tFault', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle', 'name'}).
-record('soap:tHeader', {anyAttribs, 'wsdl:required', 'namespace', 'encodingStyle', 'use', 'part', 'message', 'headerfault'}).
-record('soap:tHeaderFault', {anyAttribs, 'namespace', 'encodingStyle', 'use', 'part', 'message'}).
-record('soap:tAddress', {anyAttribs, 'wsdl:required', 'location'}).
-record('SOAP-ENV:tBinding', {anyAttribs, 'wsdl:required', 'transport', 'style'}).
-record('SOAP-ENV:tOperation', {anyAttribs, 'wsdl:required', 'soapAction', 'style'}).
-record('SOAP-ENV:tBody', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle'}).
-record('SOAP-ENV:tFaultRes', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle'}).
-record('SOAP-ENV:tFault', {anyAttribs, 'wsdl:required', 'parts', 'namespace', 'use', 'encodingStyle', 'name'}).
-record('SOAP-ENV:tHeader', {anyAttribs, 'wsdl:required', 'namespace', 'encodingStyle', 'use', 'part', 'message', 'headerfault'}).
-record('SOAP-ENV:tHeaderFault', {anyAttribs, 'namespace', 'encodingStyle', 'use', 'part', 'message'}).
-record('SOAP-ENV:tAddress', {anyAttribs, 'wsdl:required', 'location'}).

-endif.
20 changes: 10 additions & 10 deletions src/detergent.erl
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ parseMessage(Message, #wsdl{model = Model}) ->
%%
parseMessage(Message, Model) ->
case erlsom:scan(Message, Model) of
{ok, #'soap:Envelope'{'Body' = #'soap:Body'{choice = Body},
{ok, #'SOAP-ENV:Envelope'{'Body' = #'SOAP-ENV:Body'{choice = Body},
'Header' = undefined}, _} ->
{ok, undefined, Body};
{ok, #'soap:Envelope'{'Body' = #'soap:Body'{choice = Body},
'Header' = #'soap:Header'{choice = Header}}, _} ->
{ok, #'SOAP-ENV:Envelope'{'Body' = #'SOAP-ENV:Body'{choice = Body},
'Header' = #'SOAP-ENV:Header'{choice = Header}}, _} ->
{ok, Header, Body};
{error, ErrorMessage} ->
{error, {decoding, ErrorMessage}}
Expand All @@ -274,10 +274,10 @@ mk_envelope(M, H) when is_tuple(M) -> mk_envelope([M], H);
mk_envelope(M, H) when is_tuple(H) -> mk_envelope(M, [H]);
%%
mk_envelope(Messages, []) when is_list(Messages) ->
#'soap:Envelope'{'Body' = #'soap:Body'{choice = Messages}};
#'SOAP-ENV:Envelope'{'Body' = #'SOAP-ENV:Body'{choice = Messages}};
mk_envelope(Messages, Headers) when is_list(Messages),is_list(Headers) ->
#'soap:Envelope'{'Body' = #'soap:Body'{choice = Messages},
'Header' = #'soap:Header'{choice = Headers}}.
#'SOAP-ENV:Envelope'{'Body' = #'SOAP-ENV:Body'{choice = Messages},
'Header' = #'SOAP-ENV:Header'{choice = Headers}}.

%%% --------------------------------------------------------------------
%%% Parse a WSDL file and return a 'Model'
Expand Down Expand Up @@ -311,7 +311,7 @@ initModel2(WsdlFile, Prefix, Path, Import, AddFiles) ->
WsdlName = filename:join([Path, "wsdl.xsd"]),
IncludeWsdl = {"http://schemas.xmlsoap.org/wsdl/", "wsdl", WsdlName},
{ok, WsdlModel} = erlsom:compile_xsd_file(filename:join([Path, "soap.xsd"]),
[{prefix, "soap"},
[{prefix, "SOAP-ENV"},
{include_files, [IncludeWsdl]}]),
%% add the xsd model (since xsd is also used in the wsdl)
WsdlModel2 = erlsom:add_xsd_model(WsdlModel),
Expand All @@ -322,7 +322,7 @@ initModel2(WsdlFile, Prefix, Path, Import, AddFiles) ->
%% TODO: add files as required
%% now compile envelope.xsd, and add Model
{ok, EnvelopeModel} = erlsom:compile_xsd_file(filename:join([Path, "envelope.xsd"]),
[{prefix, "soap"}]),
[{prefix, "SOAP-ENV"}]),
SoapModel = erlsom:add_model(EnvelopeModel, Model),
SoapModel2 = addModels(AddFiles, SoapModel),
#wsdl{operations = Operations, model = SoapModel2}.
Expand Down Expand Up @@ -567,7 +567,7 @@ getPortsInfo([], _Name, Acc) ->

getPortsInfo([#'wsdl:tPort'{name = Name,
binding = Binding,
choice = [#'soap:tAddress'{location = URL}]} | Tail], ServiceName, Acc) ->
choice = [#'SOAP-ENV:tAddress'{location = URL}]} | Tail], ServiceName, Acc) ->
getPortsInfo(Tail, ServiceName, [#port{service = ServiceName, port = Name, binding = Binding, address = URL}|Acc]);
%% non-soap bindings are ignored.
getPortsInfo([#'wsdl:tPort'{} | Tail], ServiceName, Acc) ->
Expand Down Expand Up @@ -613,7 +613,7 @@ getOperationsFromOperations([#'wsdl:tBindingOperation'{name = Name, choice = Cho
BindingName, BindingType, Operations, Ports, Acc) ->
%% get SOAP action from Choice,
case Choice of
[#'soap:tOperation'{soapAction = Action}] ->
[#'SOAP-ENV:tOperation'{soapAction = Action}] ->
%% lookup Binding in Ports, and create a combined result
Ports2 = searchPorts(BindingName, Ports),
%% for each port, make an operation record
Expand Down
4 changes: 2 additions & 2 deletions src/detergent_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ return(Model, ResHeader, ResBody, ResCode, SessVal, Files) ->
%% add envelope
Header2 = case ResHeader of
undefined -> undefined;
_ -> #'soap:Header'{choice = ResHeader}
_ -> #'SOAP-ENV:Header'{choice = ResHeader}
end,
Envelope = #'soap:Envelope'{'Body' = #'soap:Body'{choice = ResBody},
Envelope = #'SOAP-ENV:Envelope'{'Body' = #'SOAP-ENV:Body'{choice = ResBody},
'Header' = Header2},
case catch erlsom:write(Envelope, Model) of
{ok, XmlDoc} ->
Expand Down