Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove outbound unused namespaces from soap body message

I am using CXF JAXWS Client for retrieving some information from an external web services. So, basically, we have .xsd and .wsdl files from the external and try to implement our ws consumer by generating the client stubs using cxf-codegen-plugin. We cannot change the .xsd and .wsdl files. Everything works fine, we are able to send and retrieve soap messges from the external services. However, when I look into the soap request message from the log, I find a lot of unused namespaces in the soap (body) message sent from our ws client. Below is an example

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:aheaderns="http://xxx.xxx.xxx.xxx/header.xsd">
<soap:Header>
    ...
</soap:Header>
<soap:Body>
    <ns7:requestQuery xmlns:ns15="http://xxx.xxx.xxx.xxx/AAA" xmlns:ns14="http://xxx.xxx.xxx.xxx/BBB" xmlns:ns13="http://xxx.xxx.xxx.xxx/DDD" xmlns:ns12="http://xxx.xxx.xxx.xxx/CCC" xmlns:ns11="http://xxx.xxx.xxx.xxx/EEE" xmlns:ns10="http://xxx.xxx.xxx.xxx/FFF" xmlns:ns9="http://xxx.xxx.xxx.xxx/GGG" xmlns:ns8="http://xxx.xxx.xxx.xxx/HHH" xmlns:ns7="http://xxx.xxx.xxx.xxx/III" xmlns:ns6="http://xxx.xxx.xxx.xxx/JJJ" xmlns:ns5="http://xxx.xxx.xxx.xxx/KKK">
        <ns7:sample>
            <ns7:type>A</ns7:type>
            <ns7:ref>1</ns7:ref>
        </ns7:sample>
    </ns7:requestQuery>
</soap:Body>

Is there any way to remove the unused namespaces from the outbound soap message sending from the client?

like image 980
papokk Avatar asked Nov 02 '22 14:11

papokk


1 Answers

You could move your client proxy classes to the same package and map it to the proposed namespace specified in the wsdl. Put this code into the package-info.java class:

@XmlSchema(xmlns = { @XmlNs(prefix = "ns1", namespaceURI = "http://xxx.xxx.xxx") }, 
            namespace = "http://xxx.xxx.xxx")
package clinet.sample.proxy;

import javax.xml.bind.annotation.XmlNs;

Hope this helps.

like image 172
Farzad Fallah Avatar answered Nov 15 '22 10:11

Farzad Fallah