Allwin
Allwin

Reputation: 41

Changing JAVA Axis Webservice Response XML Body

I am trying to create webservice which returns a list of vo. i am able to return the list of VO. but i need the xml structure in a particular way.

i dont know how to do it using eclipse axis.

My config

my VO structure

LookVO

name :string

id :string

i have method in webservice class as getGroupLookVO

for which i get a return xml as

<getGroupLookVOResponse>
<getGroupLookVOReturn>
<name>one</name>
<id>1</id>
</getGroupLookVOReturn>
<getGroupLookVOReturn>
<name>two</name>
<id>2</id>
</getGroupLookVOReturn>
<getGroupLookVOReturn>
<name>three</name>
<id>3</id>
</getGroupLookVOReturn>
</getGroupLookVOResponse>

The xml structure I need is

<getGroupLookVOResponse>
<getGroupLookVOReturn>
<LookVO>
<name>one</name>
<id>1</id>
</LookVO>
<LookVO>
<name>two</name>
<id>2</id>
</LookVO>
<LookVO>
<name>three</name>
<id>3</id>
</LookVO>
</getGroupLookVOReturn>
</getGroupLookVOResponse>

the method signature is

public LookVO[] getGroupLookVO()

I tried editing wsdl but as soon as i regenerate the client the wsdl gets rewritten. Also I am not good in WSDl.

Can some please help me and point me in the correct direction

Upvotes: 2

Views: 1061

Answers (1)

klebe85
klebe85

Reputation: 286

If I have got your problem, you should regenerate the webservice before, not the client.

1) change the method in THE WEBSERVICE (not in the client!) in order to have the behaviour you need

2) Right click on your WS package and then New -> Other -> Web Services -> Web Service

3) follow the wizard adding all the methods you want to publish

4) deploy your webservice on the server

and then

5) regenerate the client from the new wsdl


Just a personal remark, but it is a matter of taste. In XML the concept of order of elements within the same list should not exist, since the validation through XML Schema doesnt provide this possibility. You can generate elements in the order you want, but if you are a "purist" of well-designed XML, you should not rely on the order of tags within the same list. But, I dont want to be too much annoying on this :))

Upvotes: 1

Related Questions