普元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