Search code examples
javaweb-servicessoapwsdl

Why my entity is not recognized by SOAP WSDL service?


I have this method:

  @WebResult(name = "accountList")
public List<Account> getAllAccountWithScoreBiggerThan(@WebParam(name = "scoreValue") int scoreValue) {
    System.out.println("bigger than " + scoreValue);
    List<Account> list = dao.findAccountsWithScoreBiggerThan(scoreValue);
    return list;
}

But when I use SoapUI for test it, I get this xml:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <ns2:getAllAccountWithScoreBiggerThanResponse xmlns:ns2="http://service/">
     <accountList/>
     <accountList/>
     <accountList/>
  </ns2:getAllAccountWithScoreBiggerThanResponse>
 </soap:Body>
</soap:Envelope>

When I look at my WSDL, I got this piece:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service/" elementFormDefault="unqualified" targetNamespace="http://service/" version="1.0">
<xs:element name="getAllAccountWithScoreBiggerThan" type="tns:getAllAccountWithScoreBiggerThan"/>
<xs:element name="getAllAccountWithScoreBiggerThanResponse" type="tns:getAllAccountWithScoreBiggerThanResponse"/>
<xs:complexType name="getAllAccountWithScoreBiggerThan">
    <xs:sequence>
        <xs:element name="scoreValue" type="xs:int"/>
    </xs:sequence>
</xs:complexType>
<xs:complexType name="getAllAccountWithScoreBiggerThanResponse">
    <xs:sequence>
        <xs:element maxOccurs="unbounded" minOccurs="0" name="accountList" type="tns:account"/>
    </xs:sequence>
</xs:complexType>
<xs:complexType name="account">
    <xs:sequence/>
</xs:complexType>

Wasn't this piece supposed to list all my account atributes? How can I change my output to list my entities attributes? When debugging, I can see normally all my attributes.


Solution

  • I don't know why and I didn't find the source, but attributes need both getters and setters named accordingly to work with SOAP. After I added them, it worked perfectly