[英]Trouble returning an array through Java Web Service
I am trying to return an object which has few Strings as well an another array of Strings (there's a reason for this, I promise). 我试图返回一个对象,该对象具有几个字符串以及另一个字符串数组(我保证这是有原因的)。 The trouble I'm having is that when I test my method with SoapUI, I only get the Strings;
我遇到的麻烦是,当我用SoapUI测试我的方法时,我只会得到Strings。 the array of Strings seems to be missing entirely.
字符串数组似乎完全丢失了。 Any clue what I'm doing wrong?
任何线索我在做什么错? My class looks something like this...
我的课看起来像这样...
public class EmailListing {
public String type;
public String category;
public String[] emails;
public EmailListing() {
emails = new String[1];
}
public void setEmailList(String emaillist) {
this.emails = emaillist.split("\\|");
}
}
In the web service function that uses this class, I do the following: 在使用此类的Web服务函数中,执行以下操作:
public EmailListing getEmailListing(int id) {
EmailListing el = new EmailListing();
try {
// get data from the database
// ...
//
while(rs.next()) {
el.type = rs.getString("type");
el.category = rs.getString("category");
el.setEmailList(rs.getString("emaillist"));
}
} catch(...) {
...
}
return el;
}
The only information I see when I test this service, though, is the type and category. 但是,在测试此服务时,我看到的唯一信息是类型和类别。 :(
:(
Edit: Method for printing and results of server-side output. 编辑:打印方法和服务器端输出的结果。
public void print() {
StringBuffer sb = new StringBuffer();
sb.append("Emails\n");
for(int i = 0; i < emails.length; i++) {
sb.append(" " + emails[i] + "\n");
}
System.out.println(sb.toString());
}
Output looks like : 输出看起来像:
Emails
XXXXX@gmail.com
XXXXXXX@gmail.com
Edit: Adding recieved soap message 编辑:添加收到的肥皂消息
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getEmailListingResponse xmlns="http://services.test.com">
<getEmailListingReturn>
<type>data</type>
<category>data</category>
</getEmailListingReturn>
</getEmailListingResponse>
</soapenv:Body>
</soapenv:Envelope>
调试它,看看您是否真正得到了“ emailList”,如果是这样,您可能会错误地拆分它,因为您的代码对我来说看起来不错。
How exactly does EmailListing
look like? EmailListing
外观如何? My best guess is that you'll need to create some sort of an XmlTypeAdapter . 我最好的猜测是,您将需要创建某种XmlTypeAdapter 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.