JAXB - How to set xmlns and prefix in child tag only



I'm using JAXB to generate a soap xml request. The current xml output that i want is this



<soapenv:Envelope
xmlns:soapenv="http://ift.tt/sVJIaE"
xmlns:rgw="http:/blablablablabla.org"
xmlns:typ="http://ift.tt/1vXHont">

<soapenv:Header>

<wsse:Security
soapenv:mustUnderstand="1"
xmlns:wsse="http://ift.tt/LRW8Ij"
xmlns:wsu="http://ift.tt/Hm2joJ">

<wsse:UsernameToken wsu:Id="testToken-13">
<wsse:Username>blbalbalL</wsse:Username>
<wsse:Password
Type="http://ift.tt/1aTA7XU">1234r</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>


Until now i have generate the Envelope and Header tag but i have trouble with the Security tag.


My problem is if i try to set the xmlns to package-info.class the prefix is correct but the xmlns:wsse="blbalbla" and the xmlns:wsu="http://balbla.com" going to the root element(envelope) and not into the security tag. Here is the output that i get:



<soapenv:Envelope
xmlns:soapenv="http://ift.tt/sVJIaE"
xmlns:rgw="http://gr/gsis/rgwsalldata/RgWsAllData.wsdl"
xmlns:typ="http://gr/gsis/rgwsalldata/RgWsAllData.wsdl/types/"
xmlns:wsse="http://ift.tt/LRW8Ij"
xmlns:wsu="http://ift.tt/Hm2joJ">
<soapenv:Header>
<wsse:Security/>
</soapenv:Header>
<soapenv:Body/>


As you can see in the desire xml output the xmlns:wsse and xmlns:wsu namespaces are at the security tag. how can i these xmlns to security tag? and how can the UsernameToken tag should build?


package-info.class



@XmlSchema(
namespace = "http://ift.tt/sVJIaE",
xmlns = { @XmlNs(prefix="soapenv", namespaceURI="http://ift.tt/sVJIaE"),
@XmlNs(prefix="rgw", namespaceURI="http://blabalbalbal.org"),
@XmlNs(prefix="typ", namespaceURI="blablaba/types/"),
@XmlNs(prefix="wsse", namespaceURI="http://ift.tt/LRW8Ij"),
@XmlNs(prefix="wsu", namespaceURI="http://ift.tt/Hm2joJ")},
elementFormDefault = XmlNsForm.QUALIFIED)

package broker.jaxb.xmlrequest;

import javax.xml.bind.annotation.*;

No comments:

Post a Comment