In performance tests of our web service we found out that the traffic generated by the response exceeded our expectations a lot. We are querying the database and loading lists consisting of rows and columns.
The type of the column is AnyType so the in the response there needs to be a type information. Therefor the web service engine (Axis2 or JAXWS) adds a lot of namespace information multiple times. See the following example response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:loadListResponse xmlns:ns3="http://example.com/test/service-types-1.0"
xmlns:ns2="http://example.com/lists/lists-types-1.0" >
<ns3:value>
<ns2:row>
<ns2:column xsi:type="xs:int" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">12345</ns2:column>
<ns2:column xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">XYZ</ns2:column>
<ns2:column xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns2:column xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">ABC</ns2:column>
</ns2:row>
<ns2:row>
<ns2:column xsi:type="xs:int" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">32345</ns2:column>
<ns2:column xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">OPC</ns2:column>
<ns2:column xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns2:column xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">QWE</ns2:column>
</ns2:row>
.
.
.
</ns3:value>
</ns3:loadListResponse>
</soapenv:Body>
</soapenv:Envelope>
I would like to optimize this XML response by adding the required namespaces at the top and removing them from every column (usually there are about 30 columns per line). The result should look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<ns3:loadListResponse xmlns:ns3="http://example.com/test/service-types-1.0"
xmlns:ns2="http://example.com/lists/lists-types-1.0" >
<ns3:value>
<ns2:row>
<ns2:column xsi:type="xs:int" >12345</ns2:column>
<ns2:column xsi:type="xs:string" >XYZ</ns2:column>
<ns2:column xsi:nil="true" />
<ns2:column xsi:type="xs:string" >ABC</ns2:column>
</ns2:row>
<ns2:row>
<ns2:column xsi:type="xs:int" >32345</ns2:column>
<ns2:column xsi:type="xs:string" >OPC</ns2:column>
<ns2:column xsi:nil="true" />
<ns2:column xsi:type="xs:string" >QWE</ns2:column>
</ns2:row>
.
.
.
</ns3:value>
</ns3:loadListResponse>
</soapenv:Body>
</soapenv:Envelope>
How would you do something like that?
Is there a way to tell Axis2 or JAXWS to do so?
Or do I need to manipulate the generated XML manually?