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; 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:
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? My best guess is that you'll need to create some sort of an XmlTypeAdapter .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.