soap icon indicating copy to clipboard operation
soap copied to clipboard

Namespace not being added

Open okkdev opened this issue 4 years ago • 5 comments

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

okkdev avatar Dec 28 '20 10:12 okkdev

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

dportalesr avatar May 18 '22 05:05 dportalesr

Unfortunately not 😞

okkdev avatar May 27 '22 13:05 okkdev

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

dportalesr avatar May 27 '22 18:05 dportalesr

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.

skostojohn avatar Jan 22 '23 05:01 skostojohn

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:

  • made a template of the body of the request
  • sent the filled template with a "regular" HTTP client
  • used :sweet_xml to handle the response (also this lib's Soap.Response.parse/2 worked)

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]}

doofyus avatar Jul 12 '23 10:07 doofyus