Skip to content
Merged
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
12 changes: 9 additions & 3 deletions lib/soap/request/params.ex
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ defmodule Soap.Request.Params do

@spec get_action_with_namespace(wsdl :: map(), operation :: String.t()) :: String.t()
defp get_action_with_namespace(wsdl, operation) do
wsdl[:complex_types]
|> Enum.find(fn x -> x[:name] == operation end)
|> handle_action_extractor_result(wsdl, operation)
case wsdl[:complex_types] do
[] ->
""

_ ->
wsdl[:complex_types]
|> Enum.find(fn x -> x[:name] == operation end)
|> handle_action_extractor_result(wsdl, operation)
end
end

@spec get_header_with_namespace(wsdl :: map(), operation :: String.t()) :: String.t()
Expand Down
38 changes: 38 additions & 0 deletions test/fixtures/wsdl/CyberSourceTransaction.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CyberSourceTransactionWS" targetNamespace="urn:schemas-cybersource-com:transaction-data:TransactionProcessor" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:schemas-cybersource-com:transaction-data:TransactionProcessor" xmlns:data="urn:schemas-cybersource-com:transaction-data-1.147">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="urn:schemas-cybersource-com:transaction-data-1.147" schemaLocation="CyberSourceTransaction_1.147.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="messageIn">
<wsdl:part name="input" element="data:requestMessage"/>
</wsdl:message>
<wsdl:message name="messageOut">
<wsdl:part name="result" element="data:replyMessage"/>
</wsdl:message>
<wsdl:portType name="ITransactionProcessor">
<wsdl:operation name="runTransaction">
<wsdl:input name="inputMessageIn" message="tns:messageIn"/>
<wsdl:output name="outputMessageOut" message="tns:messageOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ITransactionProcessor" type="tns:ITransactionProcessor">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="runTransaction">
<soap:operation soapAction="runTransaction" style="document"/>
<wsdl:input name="inputMessageIn">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="outputMessageOut">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TransactionProcessor">
<wsdl:documentation>CyberSource Web Service</wsdl:documentation>
<wsdl:port name="portXML" binding="tns:ITransactionProcessor">
<soap:address location="https://ics2wsa.ic3.com:443/commerce/1.x/transactionProcessor"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header/><env:Body><runTransaction/></env:Body></env:Envelope>
8 changes: 8 additions & 0 deletions test/soap/request/params_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ defmodule Soap.Request.ParamsTest do
"Element date has wrong format. Expects [0-9]{4}-[0-9]{2}-[0-9]{2} format."
]
end

test "#build_body without complex types" do
xml_body = Fixtures.load_xml("cyber_source_transaction/runTransactionRequest.xml")
{_, wsdl} = Wsdl.parse_from_file(Fixtures.get_file_path("wsdl/CyberSourceTransaction.wsdl"))
function_result = Params.build_body(wsdl, "runTransaction", %{}, nil)

assert function_result == xml_body
end
end