FAQ
I want to build an xml structure for a soap request that looks like this:

<soap12:Header>
<Security
xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>string</Username>
<Password>string</Password>
</UsernameToken>
</Security>
<PartnerInformation xmlns="http://services.digikey.com/SearchWS">
<PartnerID>guid</PartnerID>
</PartnerInformation>
</soap12:Header>


And if I try and marshall these structs;

type Security struct{
XMLName xml.Name `xml:"Security"`
Xmlns string `xml:"xmlns,attr"`
Username string `xml:"UsernameToken>Username"`
Password string `xml:"UsernameToken>Password"`
}

type PartnerInformation struct{
XMLName xml.Name `xml:"PartnerInformation"`
Xmlns string `xml:"xmlns,attr"`
PartnerID string `xml:"PartnerID"`
}

type Header struct{
XMLName xml.Name `xml:"soap12:Header"`
Security
PartnerInformation
}

I get this error:

error: main.Header field "Xmlns" with tag "xmlns,attr" conflicts with field "Xmlns" with tag "xmlns,attr"


http://play.golang.org/p/SWjnAzSy39


I'm guessing there's a good reason why I can't do it like this. Any ideas for ways around this?


Cheers!


--

Search Discussions

  • Daniel Morsing at Nov 28, 2012 at 2:38 pm

    On Wed, Nov 28, 2012 at 9:01 AM, wrote:
    type Header struct{
    XMLName xml.Name `xml:"soap12:Header"`
    Security
    PartnerInformation
    }
    Embedding makes the xml package try to pull the subelements into the
    parent. In this case it tries to make the attributes you gave to
    Security and PartnerInformation be part of Header. Since they both
    have an xmlns attribute, there is a conflict there.

    You can fix this by giving the Security and PartnerInformation fields
    an exported name, Eg. Sec and Partner.

    Regards,
    Daniel Morsing

    --
  • Pietgeursen at Nov 28, 2012 at 6:19 pm
    Nice! That does the job. Thanks!
    On Thursday, November 29, 2012 3:37:58 AM UTC+13, Daniel Morsing wrote:

    On Wed, Nov 28, 2012 at 9:01 AM, <pietg...@gmail.com <javascript:>>
    wrote:
    type Header struct{
    XMLName xml.Name `xml:"soap12:Header"`
    Security
    PartnerInformation
    }
    Embedding makes the xml package try to pull the subelements into the
    parent. In this case it tries to make the attributes you gave to
    Security and PartnerInformation be part of Header. Since they both
    have an xmlns attribute, there is a conflict there.

    You can fix this by giving the Security and PartnerInformation fields
    an exported name, Eg. Sec and Partner.

    Regards,
    Daniel Morsing
    --
  • Barthels at Nov 28, 2012 at 8:19 pm
    Hi, I've tried to register for a partner ID @ digikey two weeks ago, but it
    seems that no one there knows anything about it. If you managed to get a
    valid partner GUID, could you please tell me how to register for it?

    Thank you very much!

    Daniel

    --
  • Piet Geursen at Nov 28, 2012 at 6:33 pm
    Hi Daniel,
    I don't have a GUID yet either. I emailed web.services@digikey.com a week
    ago and haven't heard anything back.

    How did you go about registering for it? Did you just email that address or
    did you do something else?

    If you find out how to do it let me know, and I will you, ok? :)

    Cheers,
    Piet



    On Thu, Nov 29, 2012 at 6:46 AM, wrote:

    Hi, I've tried to register for a partner ID @ digikey two weeks ago, but
    it seems that no one there knows anything about it. If you managed to get a
    valid partner GUID, could you please tell me how to register for it?

    Thank you very much!

    Daniel
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 28, '12 at 2:02p
activeNov 28, '12 at 8:19p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase