【问题标题】:Soap web service not getting published for Custom Object return type in Java未针对 Java 中的自定义对象返回类型发布 Soap Web 服务
【发布时间】:2017-10-18 07:02:39
【问题描述】:

我正在编写一个肥皂网络服务。我有一个方法应该返回一个自定义对象 ResultDto。当我将它作为返回类型添加到我的方法时,不会生成 wsdl 文件。但是当我将返回类型保留为字符串时,它工作正常。 这里有什么问题?如何返回自定义对象。

@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 

}

ResultDto

 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "ResultDto")

 public class ResultDto {

 public String status;

 public String errorMessage;
 public int errorCode;

 // Getterrs and setters 
 }

【问题讨论】:

    标签: java web-services soap wsdl


    【解决方案1】:

    你必须把 @WebResult(name="ResultDto") 放在你的方法之前

    @WebService
    public interface Transaction {
        @WebMethod(action="createPurchase", operationName = "purchase")
        @WebResult(name="ResultDto")
        ResultDto purchase(String partyId, String dealId); 
     }
    

    【讨论】:

      猜你喜欢
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 2010-12-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多