如何为Oracle Web Service定义XML有效内容结构?

时间:2014-07-29 16:30:57

标签: java xml oracle soap weblogic

到目前为止,我已经编写了一个查询现有数据库并获取信息的服务。它将信息写入类,然后将其添加到所述类的列表中。

@WebMethod 
@WebResult(name = "thing")
public List<Role> getThing {

    List<Thing> things = new ArrayList();

    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    try {
        connection = Utils.getConnection();

        statement = connection.prepareStatement(PREPARED_STATEMENT);

        rs = statement.executeQuery();

        while(rs.next()){

            Thing thing = new Thing();

            thing.setONE(rs.getString("COLUMN_1"));
            thing.setTWO(rs.getString("COLUMN_2"));
            thing.setTHREE(rs.getString("COLUMN_3"));

            things.add(thing);

        }
    } catch (Exception e) { 
        Utils.logException("ERROR");
    } finally {

        Utils.closeConnection(connection);
        Utils.closeResultSet(rs);
        Utils.closeStatement(statement);
    }
    return things;
}

XML输出需要如下所示:

<thing row=1>
    <ONE type="VARCHAR2" size=(size)>Thingy number One</ONE>
    <TWO type="VARCHAR2" size=(size)>Thingy number One</TWO>
    <THREE type="VARCHAR2" size=(size)>Thingy number One</THREE>
</thing>
<thing row=2>
    <ONE type="VARCHAR2" size=(size)>OTHER Thingy number One</ONE>
    <TWO type="VARCHAR2" size=(size)>OTHER Thingy number One</TWO>
    <THREE type="VARCHAR2" size=(size)>OTHER Thingy number One</THREE>
</thing>

如何对java web服务进行注释,以便在使用WSDL时输出该结构?

谢谢!

0 个答案:

没有答案