I created a web service using JAX-WS in RSA 7.5 and Websphere 7 using bottom-up approach. When I open the WSDL in SOAP UI, then the arguments section is appearing like this:
<!--Optional-->
<arg0>
<empID>?</empId>
</arg0>
<!--Optional-->
<arg1>
<empName>?</empName>
</arg1>
<!--Optional-->
<arg2>
<empAddress>?</empAddress>
</arg2>
<!--Optional-->
<arg3>
<empCountry>?</empCountry>
</arg3>
The service method takes the above 4 elements as the parameters to return the employee details.
1) I want to rename this arg0, arg1, and so on with some valid names.
2) I want to remove the <!--optional-->
present above the arg tags. (For removing the <!--optional-->
from elements name, I used @XMLElement(required=true)). But I am not sure where exactly to use this annotation in this case :(
Please help.
Regards,
You put the @XMLElement(required=true)
above the variables in your class that are being returned from your service. I just learned about that option about a month ago. So right above where you declare empName put the tag and required.
To rename the parameters of your service use the @WebParam(name="<name you want in soap>")
in front of each input variable to the service.
For example, if you have a service method called get(String name)
it would look something like get(@WebParam(name = "name") String name)
You are correct, now that I read your comment again. The services I support use Objects in the input and output, which is why I put the XMLElement tag in the class of those objects.
You need to put the tag in the class that declares your variables that are passed in or returned to the service. If those happen to be declared in your service class that is fine. The main point is that you put that XMLElement tag above the variable declaration, versus putting it on a getter or setter.
This tutorial shows some examples of the usage. JAXB tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With