Note that there are some explanatory texts on larger screens.

plurals
  1. PO@XmlElement(required=true) for @WebParam does not work
    primarykey
    data
    text
    <p>I'm building web service using JAX-WS. I have a strange problem that the annotation <code>@XmlElement(required=true)</code> for <code>@WebParam</code> works in some <code>@WebService</code> class, but doesn't work in some others.</p> <p>I have very similar code in the two <code>@WebService</code> classes. What may cause this problem? Parameter type or the entity class?</p> <p><strong>Edit: Add sample code</strong></p> <p>I have two web services:</p> <pre><code>@WebService(name = "ClubMemberPortType", serviceName = "ClubMemberService", portName = "ClubMemberSoapPort", targetNamespace = "http://club.com/api/ws") public class ClubMemberWS { @WebMethod(operationName = "findClubMembersByClubId", action = "urn:findClubMembersByClubId") @WebResult(name = "club_membership") public List&lt;ClubMembership&gt; findClubMembershipsByClubId(@XmlElement(required=true) @WebParam(name = "club_id") String clubId, @WebParam(name = "status") StatusEnum status){ ... }} </code></pre> <p>and</p> <pre><code>@WebService(name = "ClubPortType", serviceName = "ClubService", portName = "ClubSoapPort", targetNamespace = "http://club.com/api/ws") public class ClubWS { @WebMethod(operationName = "findClubByClubId", action = "urn:findClubByClubId") @WebResult(name = "club") public Club findClubByClubId(@XmlElement(required=true) @WebParam(name = "club_id") String clubId) { ... }} </code></pre> <p>The generated schema for the first web method is:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://club.com/api/ws"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;ws:findClubMembersByClubId&gt; &lt;club_id&gt;?&lt;/club_id&gt; &lt;!--Optional:--&gt; &lt;status&gt;?&lt;/status&gt; &lt;/ws:findClubMembersByClubId&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>The generated schema for the second web method is:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://club.com/api/ws"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;ws:findClubByClubId&gt; &lt;!--Optional:--&gt; &lt;club_id&gt;?&lt;/club_id&gt; &lt;/ws:findClubByClubId&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>So the first one works fine, the second one does not work. How is it possible? :(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload