Hi
We are using PayloadRootAnnotationMethodEndpointMapping and JAXB2Marshaller. When the soap result is generated the namespace declaration is repeated for each element. This results in huge xml
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Header></env:Header>
<env:Body>
<ns1:RootElement xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">
<ns1:Child1 xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">Childvalue </ns1:Child1>
<ns2:Child2 xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">Childvalue</ns1:Child2>
<ns3:Child3 xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">Childvalue</ns3:Child3>
<ns4:Child4 xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">Childvalue</ns4:Child4>
</ns1:RootElement>
</env:Body>
</env:Envelope>
While debugging with my limited understanding I think that that the startElement method in SaajContentHandler is adding this
for (Iterator iterator = namespaces.keySet().iterator(); iterator.hasNext(){
String namespacePrefix = (String) iterator.next();
String namespaceUri = (String) namespaces.get(namespacePrefix);
child.addNamespaceDeclaration(namespacePrefix, namespaceUri);
}
I would appreciate help in preventing the redeclaration of namespace. In the sample above I would like the xml to be like this as the namespaces are already declared in parent.
<ns1:RootElement xmlns:ns1="urn:main" xmlns:ns2="urn:common" xmlns:ns3="urn:types">
<ns1:Child1>Childvalue </ns1:Child1>
<ns2:Child2>Childvalue</ns1:Child2>
<ns3:Child3>Childvalue</ns3:Child3>
<ns4:Child4 >Childvalue</ns4:Child4>
</ns1:RootElement>


{
Reply With Quote