Renaming an argument name in JAX-WS

I created a web service using JAX-WS in RSA 7.5 and Websphere 7 using a bottom-up approach. When I open WSDL in the SOAP user interface, the argument section looks like this:

<!--Optional--> <arg0> <empID>?</empId> </arg0> <!--Optional--> <arg1> <empName>?</empName> </arg1> <!--Optional--> <arg2> <empAddress>?</empAddress> </arg2> <!--Optional--> <arg3> <empCountry>?</empCountry> </arg3> 

This service method includes 4 elements as parameters for returning information about employees.

1) I want to rename this arg0, arg1, etc. with some valid names.

2) I want to remove the <!--optional--> located above the arg tags. (To remove the element name <!--optional--> , I used @XMLElement (required = true)). But I don’t know where exactly to use this annotation in this case :(

Please, help.

Hi,

+7
source share
1 answer

You put @XMLElement (required = true) above the variables in your class that are returned from your service. I just found out about this option about a month ago. So, right here where you declare empName, put the tag and be sure.

To rename your service settings, use @WebParam (name = "") before each input variable to the service.

For example, if you have a get (String name) service method, it will look like get (@WebParam (name = "name") String name)


You are right, now I read your comment again. The services that I support use objects in the input and output file, so I put the XMLElement tag in the class of these objects.

You need to put a tag in a class that declares variables that have been passed or returned to the service. If this is announced in your class of service, this is normal. The main thing is that you put this XMLElement tag above the variable declaration, rather than putting it on a getter or setter.

This manual contains examples of use. JAXB Tutorial

+12
source

All Articles