Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace problem #243

Open
Mantany opened this issue Oct 16, 2022 · 3 comments
Open

Namespace problem #243

Mantany opened this issue Oct 16, 2022 · 3 comments

Comments

@Mantany
Copy link

Mantany commented Oct 16, 2022

During testing, I found the following error:

  1. use the following WSDL
  2. generate the go-code

Results in the following generated Request (getVServers)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <getVServers xmlns="http://enduser.service.web.vcp.netcup.de/">
            <loginName>XXXXXX</loginName>
            <password>XXXXXX</password>
        </getVServers>
    </soap:Body>
</soap:Envelope>

But it should be generated into something like this to work:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://enduser.service.web.vcp.netcup.de/">
   <soapenv:Header/>
   <soapenv:Body>
      <end:getVServers>
         <loginName>XXXX</loginName>
         <password>XXXX</password>
      </end:getVServers>
   </soapenv:Body>
</soapenv:Envelope>

Can I configure the SOAP Client to use the right namespaces (soapenv and end)?

@xunfeng1980
Copy link

+1

1 similar comment
@holgertidemand
Copy link

+1

@smingam
Copy link

smingam commented Apr 27, 2023

Hi guys, I'm facing that kind of issue too.
You need to adapt the SOAP structs to your needs in soap.go, which means forking this repo with your modifications, not an ideal situation.

For example, your SOAPEnvelope struct should be something like that, notice the soapenv in the xml struct tag :

type SOAPEnvelope struct {
	XMLName xml.Name `xml:"soapenv:Envelope"`
	XmlNS   string   `xml:"xmlns:soapenv,attr"`
	XmlCustomNS   string   `xml:"xmlns:end,attr"`

	Header *SOAPHeader
	Body   SOAPBody
}

type SOAPHeader struct {
	XMLName xml.Name `xml:"soapenv:Header"`

	Headers []interface{}
}

type SOAPBody struct {
	XMLName xml.Name `xml:"soapenv:Body"`
...
}

You will need to set your XmlCustomNS in the SOAPEnv instance :

XmlNS: XmlNsSoapEnv,

envelope := SOAPEnvelope {
		XmlNS: XmlNsSoapEnv,
		XmlCustomNS: "http://enduser.service.web.vcp.netcup.de/",
}

I'm kinda thinking it could be a good use of the new golang generics : define your types and pass them at runtime to the soap Client... keep an eye on my fork, if I get around to implement that.

For <end:getVServers> unfortunately, this "end" prefix depends on the templates used to generate the go code and I'm still wondering how to change that.
If you look at :

XMLName xml.Name ` + "`xml:\"{{$targetNamespace}} {{$type}}\"`" + `

That's where the "xmlns="url..." comes from, but we want a prefix to the xml tag name instead.

Roxxers added a commit to insurancerevolution/gowsdl that referenced this issue Feb 14, 2024
this is related to an issue on the main branch hooklift#243  We are just hardcoding a fix for opengi use within the org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants