简体   繁体   English

为何SOAP WSDL服务无法识别我的实体?

[英]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: 但是,当我使用SoapUI对其进行测试时,我得到以下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: 当我查看WSDL时,得到了以下内容:

<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. 调试时,我通常可以看到所有属性。

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. 我不知道为什么,也没有找到源,但是属性需要同时命名为getter和setter才能使用SOAP。 After I added them, it worked perfectly 我添加它们后,它运行良好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM