On Fri, Jan 30, 2009 at 10:22 AM, Upananda Singh < [email protected]> wrote:
> Hi all, > > > > I am facing a problem with Axis2 response regarding unwanted empty > tags/attributes in the response xml, > > please go through the following explanations and example…. > > I need to remove the empty tags that are coming in the response, even if not > > set in the server side. I want to remove the empty tags from the response > coming > > from the axis2 deployed service as .aar > > The same is working fine using JBoss4.2.2 deployment where the empty tags > are automatically > removed while sending back the response to client. I verified the empty > tags in the etheral logs as well > as through soap UI. > > sample response with empty tags... > > ----------------------------------------------------------------------------------- > > <?xml version='1.0' encoding='UTF-8'?> > <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> > > <soapenv:Body> > <ns:createProfileResponse xmlns:ns="http://example"> > <ns:return xmlns:ax230="http://example/xsd" type="example.Response"> > *<ax230:desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:nil="true"/> > ** > *<ax230:respCode>0000</ax230:respCode> > <ax230:respStr>Your name - hello, Age- 1</ax230:respStr> > *<ax230:tokenId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:nil="true"/>* > </ns:return> > </ns:createProfileResponse> > </soapenv:Body> > </soapenv:Envelope> > ----------------------------------------------------------------------------------- > > > The tags (attributes) in read are empty tags which I don't want in soap > response at all. This is something to > do with backward compatibility. If the older client does not know of a > newly added attribute/tag in > the new version, it will fail while parsing the response. This is not an > issue with both the server and clients > as java but will be an issue if the client is non java and will fail. > > what I want is the following without the empty tag... > > ----------------------------------------------------------------------------------- > > <?xml version='1.0' encoding='UTF-8'?> > <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> > > <soapenv:Body> > <ns:createProfileResponse xmlns:ns="http://example"> > <ns:return xmlns:ax230="http://example/xsd" type="example.Response"> > <ax230:respCode>0000</ax230:respCode> > <ax230:respStr>Your name - hello, Age- 1</ax230:respStr> > </ns:return> > </ns:createProfileResponse> > </soapenv:Body> > </soapenv:Envelope> > ----------------------------------------------------------------------------------- > > > > Ideally spaking if any empty tag is there it should be removed by default > which works fine if > I deploy the service in JBoss. But is not if I deploy it on Axis2 + Tomcat > environment (Axis2 1.4.1). > > > > Any suggestion / response is highly appreciated, > Thanks in advance... > Do you use wsdl2java tool to generate the code. if so set the minOccurs=0 for the elements you don't need. However keep in mind that removing parts in the response message may make that response not compatible with the wsdl. You can also use the WSO2 ESB (or Apache/synapse) to do any manipulation to the request/response messages using it as a proxy to the actual service. thaanks Amila. > > > With Best Regds, > > Upananda Singha > > ------------------------------------------------------- > > > -- Amila Suriarachchi WSO2 Inc. blog: http://amilachinthaka.blogspot.com/
