elixir-soap / soap

SOAP client for Elixir programming language
MIT License
135 stars 75 forks source link

XSD file is not being parsed #87

Closed okkdev closed 3 years ago

okkdev commented 3 years ago

Hi, I'm working with soap for the first time and struggling building a request with this library. I need my request to have a specific namespace to work. It should look like this:

<SOAP-ENV:Body>
  <ns1:PingRequest xmlns:ns1="http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes">
    <ns1:Echo>Hello</ns1:Echo>
  </ns1:PingRequest>
</SOAP-ENV:Body>

But what I currently get is:

<SOAP-ENV:Body>
  <PingRequest>
    <Echo>Hello</Echo>
  </PingRequest>
</SOAP-ENV:Body>

How can I add the ns1 namespace?

I attached the WSDL file. Customer.zip

kristofvanwoensel commented 3 years ago

I'm having the exact same issue.

okkdev commented 3 years ago

I noticed that the xsd is not being parsed correctly.

Soap.Xsd.parse("wsdl/AbaConnectTypes.xsd")
    |> IO.inspect()
{:ok, %{complex_types: %{}, simple_types: []}}

I attached the XSD file. AbaConnectTypes.zip

kristofvanwoensel commented 3 years ago

I solved the issue by manually changing the xml-body:

   body = Soap.Request.Params.build_body(wsdl, operation, params, request_headers)
    body = String.replace(body, "Envelope xmlns:", "Envelope xmlns:wsdl")
    HTTPoison.post(url, body, request_headers, opts)
okkdev commented 3 years ago

I guess that works, but I'd prefer a proper fix.

okkdev commented 3 years ago

As a soap beginner I didn't notice at first, but apparently my xsd file is using the non standard xs prefix instead of the xsd prefix. Once I replaced these it worked fine.