微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

普元7.2发布WebService

普元7.2发布WebService要求:

1.必须有接口。类必须实现某个接口

2.访问效果如下

3.代码

接口:

package com.primeton.eos;

import org.osoa.sca.annotations.Remotable;

@Remotable
public interface IOrgOper {
    public String executesql(String dsName);
}

实现类:

package com.primeton.eos;

import static com.eos.system.annotation.ParamType.CONSTANT;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.sqlException;
import java.sql.Statement;

import org.osoa.sca.annotations.Remotable;

import com.eos.common.connection.ConnectionHelper;
import com.eos.system.annotation.Bizlet;
import com.eos.system.annotation.BizletParam;

@Remotable
public class OrgOper implements IOrgOper {
    @Bizlet(value = "执行一条sql",params = { @BizletParam(index = 0,defaultValue = "default",type = CONSTANT) })
    //加@Bizlet这一行使executesql方法成为运算逻辑,供构件调用
    public String executesql(String dsName) {
        String result = "";
        if (dsName == null || dsName.length() == 0)
            dsName = "default";
        Connection conn = ConnectionHelper
                .getCurrentContributionConnection(dsName);
        Statement stmt = null;
        try {
            stmt = conn.createStatement();
            String sql = "select * from org where orgid=1";
            ResultSet rs = stmt.executeQuery(sql);
            while (rs.next()) {
                result = rs.getString("ORGNAME");
            }
        } catch (Throwable e) {
            throw new RuntimeException(e);
        } finally {
            close(stmt);
            close(conn);
        }
        return result;
    }

    private static void close(Connection conn) {
        if (conn == null)
            return;
        try {
            conn.close();
        } catch (sqlException e) {
            // ignore
        }
    }

    private static void close(Statement stmt) {
        if (stmt == null)
            return;
        try {
            stmt.close();
        } catch (sqlException e) {
            // ignore
        }
    }
}

代码目录:

访问方式:http://127.0.0.1:8080/default/OrgOperService?wsdl

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐