【问题标题】:Single object mapped to multiple objects in response of Web Service单个对象映射到多个对象以响应 Web 服务
【发布时间】:2013-02-10 18:46:44
【问题描述】:

我编写了一个 java 服务类并基于该类创建了一个 Web 服务(使用 eclipse Juno 和 Apache 作为 Web 服务器)。我的服务方法的返回类型是 ProductInfoOutput,内部由 ProductInfo 和 ResponseStatus 组成。但是当我在 WSDL 文件中看到时,我发现两个基于 ResponseStatus 的对象。我不知道为什么。也许在开发时我这样做了,但现在 ProductInfoOutput 只有一个 ResponseStatus 实例。您能否建议我如何从 WSDL 中删除这个额外的对象。以下是来自 WSDL 的部分。

<complexType name="ProductInfoOutput">
<sequence>
 <element name="productInfo" nillable="true" type="tns1:ProductInfo"/>
 <element name="responseStatus" nillable="true" type="tns1:ResponseStatus"/>
 <element name="response" nillable="true" type="tns1:ResponseStatus"/>
</sequence>
</complexType>

服务类:

ProductInfoOutput productInfoOutput;
DatabaseQueries query;

public ProductInfoOutput getProductInfo(String barcode) {
    productInfoOutput=new ProductInfoOutput();
    query=new DatabaseQueries();
    productInfoOutput=query.retrieveSingleProductByBarcode(barcode);
    return productInfoOutput;
}

【问题讨论】:

  • 请向我们展示映射到此的 Java 代码。
  • 这是使用 eclipse 自动生成的。右键单击服务类 -> Web 服务 -> 创建 Web 服务。在问题中更新了我的服务类。

标签: java web-services


【解决方案1】:

经过两天的浪费,我找到了问题的根本原因。项目中有一个 server-config.wsdd 文件,它是您第一次创建 Web 服务时自动创建的,即使您更新业务类也不会更新。我从 wsdd 手动删除了服务,并从业务类重新创建了 Web 服务。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-06
    • 2016-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 2021-04-28
    • 1970-01-01
    相关资源
    最近更新 更多