[英]Soap web service not getting published for Custom Object return type in Java
I'm writing a soap web service. 我正在写一个肥皂网络服务。 I have a method which should returns a custom object ResultDto. 我有一个应该返回自定义对象ResultDto的方法。 When I add it as a return type to my method, the wsdl file doesnt get generate. 当我将其添加为方法的返回类型时,wsdl文件不会生成。 But when I keep the return type as String, it works fine. 但是当我将返回类型保留为String时,它可以正常工作。 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 您必须在方法之前放置@WebResult(name =“ ResultDto”)
@WebService
public interface Transaction {
@WebMethod(action="createPurchase", operationName = "purchase")
@WebResult(name="ResultDto")
ResultDto purchase(String partyId, String dealId);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.