I'm writing a soap web service. I have a method which should returns a custom object ResultDto. When I add it as a return type to my method, the wsdl file doesnt get generate. But when I keep the return type as String, it works fine. What is the issue here? How can I return a custom object.
@WebService
public interface Transaction {
@WebMethod(action="createPurchase", operationName = "purchase")
ResultDto purchase(String partyId, String dealId); --> This does not work
String purchase(String partyId, String dealId); --> This works
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResultDto")
public class ResultDto {
public String status;
public String errorMessage;
public int errorCode;
// Getterrs and setters
}
You have to put @WebResult(name="ResultDto") before your method
@WebService
public interface Transaction {
@WebMethod(action="createPurchase", operationName = "purchase")
@WebResult(name="ResultDto")
ResultDto purchase(String partyId, String dealId);
}
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.