elixir-soap / soap

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

Namespace not being added #89

Open okkdev opened 3 years ago

okkdev commented 3 years ago

When I try to use any actions from my WSDL file the namespace is missing from the request, thus resulting in an invalid request.

It should look like this:

<env:Body>
    <login xmlns:ns1="http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes">
        <ns1:UserLogin>
            <ns1:Mandant>1</ns1:Mandant>
            <ns1:Password>pass</ns1:Password>
            <ns1:UserName>user</ns1:UserName>
        </ns1:UserLogin>
    </login>
</env:Body>

But what I currently get is:

<env:Body>
    <login>
        <UserLogin>
            <Mandant>1</Mandant>
            <Password>pass</Password>
            <UserName>user</UserName>
        </UserLogin>
    </login>
</env:Body>

This is my code:

{:ok, wsdl} = Soap.init_model("wsdl/Customer.wsdl", :file)

params = %{
  UserLogin: %{
    Mandant: "1",
    Password: "pass",
    UserName: "user"
  }
}

{:ok, response} = Soap.call(wsdl, "login", params)

Is this a problem with my wsdl or is it not being added by the lib?

Here is my wsdl and the xsds wsdl.zip

dportalesr commented 2 years ago

Hey, did you ever figured this out? I'm stuck with the same problem. Not sure what I'm missing...

okkdev commented 2 years ago

Unfortunately not 😞

dportalesr commented 2 years ago

I did. Turned out to be an inconsistent namespace definition in the WSDL I was targeting.

skostojohn commented 1 year ago

I am struggling with this issue currently - trying to use this client with the Salesforce WSDL. I can provide more details (wsdl, request body being generated by soap, example of "correct" request body, etc. if anyone has interest and bandwidth to try and help.

doofyus commented 1 year ago

I've had issues with the namespace problem too - got it working by going over the lib's code and seeing that it's using some configurations (it helped initially):

config :soap, :globals,
  env_namespace: "soapenv",
  version: "1.1",
  custom_namespaces: %{
    aut: "some_action_url",
    veh: "some_other_action_url"
  }

Unfortunately, after a few days, the lib doesn't build the correct request again and i had to use a "hacky" way to do the requests:


EDIT / UPDATE: After digging around the lib, i found that my issue was that the wsdl that i'm using doesn't have complex_types filled (they're linked from another location, but the lib isn't able to / doesn't read them) - that data was needed for my problem (action-namespace mismatch) to be gone.

For my case, the solution was like this:


extra_complex_type = %{
  name: "action_name",
  type: "name_space:action_name"
}

wsdl = %{wsdl | complex_types: [extra_complex_type | wsdl.complex_types]}