分享
 
 
 

通过JAVA、VB访问SAS IOM服务器

王朝java/jsp·作者佚名  2006-05-23
窄屏简体版  字體: |||超大  

通过IOM(“Integrated Object Model” )服务器,没有必要使SAS安装在本地系统,通过Management Console和Enterprise Guide工具可以完美的连接到远端的SAS主机上

需要注意的是IOM服务器并不是代表一个具体的服务器,在SAS IT中,有下面4中类型的IOM服务器

Metadata 服务器 – 存储和管理元数据库,包含哪些SAS服务器、库、和存储过程可用

工作空间服务器 – 维护SAS程序环境;

存储过程服务器 – 运行 “canned” SAS程序

OLAP服务器 – 驱动CUBE数据到SAS Enterprise Guide或者其它OLAP客户端

工作空间服务器有下面3中类型

JAVA客户端连接到IOM服务器使用JAVA-IOM桥

WIN客户端连接到IOM服务器使用COM/DCOM技术,

WIN客户端可以连接到运行在UNXI上的IOM服务器,通过使用COM-IOM桥

对于WIN应用,IOM支持ADO通过OLEDB访问SAS数据

对应JAVA,JDBC2.0访问是被支持的

工作空间服务器包含下面接口

工作空间Workspace – SAS会话

语言服务Language Service –提交SAS DATA步和过程步,接收LOG和LIST输出,运行存储过程

数据服务Data Service – 管理SAS库

文件服务File Service – 管理文件标识

实用工具Utilities – formats, options, result packages, host system information

存储过程服务器

用于存放存储过程,其结果可以被WEB(Information Delivery Portal,BI WEB服务)、OFFICE(OFFICE插件)或者Enterprise Guide 3.0使用

假设在SAS服务器上存在下面文件

C:\temp>type IOMTest.sas

%let cond=;

*ProcessBody;

proc print data=sashelp.class;

title "Test Stored Process";

where &cond;

run;

VB例子:

必须引用下面库

SAS: Integrated Object Model (SAS System 9.1)

SASWorkspaceManager 1.1 Type Library

Connecting with DCOM in Visual Basic

Option Explicit

' define a global workspace

Dim obSAS As SAS.Workspace

Dim obWSMgr As New SASWorkspaceManager.WorkspaceManager

Private Sub Form_Load()

Dim xmlInfo As String

' create Workspace server

Dim obServer As New SASWorkspaceManager.ServerDef

obServer.MachineDNSName = "hunding"

Set obSAS = obWSMgr.Workspaces.CreateWorkspaceByServer _

("", VisibilityProcess, obServer, "", "", xmlInfo)

End Sub

Private Sub cmdTest1_Click()

' use LanguageService to submit code

obSAS.LanguageService.Submit _

"%include 'c:\temp\IOMTest.sas'; run;"

MsgBox obSAS.LanguageService.FlushLog(100000)

MsgBox obSAS.LanguageService.FlushList(100000)

End Sub

Private Sub cmdTest2_Click()

'run the stored SAS program

Dim obStoredProcessService As SAS.StoredProcessService

Set obStoredProcessService = _

obSAS.LanguageService.StoredProcessService

obStoredProcessService.Repository = "file:c:\temp"

obStoredProcessService.Execute "IOMtest", "cond='sex eq ""M""'"

MsgBox obSAS.LanguageService.FlushLog(100000)

MsgBox obSAS.LanguageService.FlushList(1000000)

End Sub

Private Sub Form_Unload(Cancel As Integer)

obWSMgr.Workspaces.RemoveWorkspaceByUUID _

obSAS.UniqueIdentifier

obSAS.Close

End Sub

VC例子

#include <iostream>

#include <stdexcept>

#include <windows.h>

using namespace std;

#import "C:\Program Files\SAS Institute\Shared Files\Integration

Technologies\sas.tlb"

#import "C:\Program Files\SAS Institute\Shared Files\Integration

Technologies\SASWMan.dll"

int main()

{

SASWorkspaceManager::IWorkspaceManager2Ptr pIWorkspaceManager;

SASWorkspaceManager::IServerDef2Ptr pIServerDef = NULL;

SAS::IWorkspacePtr pIWorkspace;

BSTR xmlInfo;

HRESULT hr = CoInitialize(NULL);

hr = pIWorkspaceManager.CreateInstance(

"SASWorkspaceManager.WorkspaceManager.1");

pIServerDef.CreateInstance("SASWorkspaceManager.ServerDef");

pIServerDef->PutMachineDNSName("hygelac");

pIServerDef->Protocol = SASWorkspaceManager::ProtocolBridge;

pIServerDef->put_Port(8591);

pIWorkspace = pIWorkspaceManager->Workspaces->CreateWorkspaceByServer(

_bstr_t(""), //workspace name

SASWorkspaceManager::VisibilityProcess,

pIServerDef, // server

_bstr_t("sassrv"), // login

_bstr_t("sasuser"), // password

&xmlInfo // connection log

);

pIWorkspace->LanguageService->Submit(

"%include '/home/sasadm/IOMTest.sas'; run;");

MessageBox(NULL,

pIWorkspace->LanguageService->FlushLog(10000),

"SAS Log",

MB_OK

);

MessageBox(NULL,

pIWorkspace->LanguageService->FlushList(10000),

"List Output",

MB_OK

);

pIWorkspace->Close();

return(0);

}

JAVA客户端

编译时使用下面命令

javac -classpath ".:C:/Program Files/SAS/SAS 9.1/core/sasmisc/sas.svc.connection.jar" IOMTest.java

sas.svc.connection.jar文件位于 C:\Program Files\SAS\SAS 9.1\core\sasmisc 下

例子代码如下:

import com.sas.services.connection.Server;

import com.sas.services.connection.BridgeServer;

import com.sas.services.connection.ConnectionFactoryConfiguration;

import com.sas.services.connection.ConnectionFactoryManager;

import com.sas.services.connection.ConnectionFactoryInterface;

import com.sas.services.connection.ConnectionFactoryException;

import com.sas.services.connection.ConnectionInterface;

import com.sas.services.connection.ManualConnectionFactoryConfiguration;

import com.sas.iom.SAS.IWorkspace;

import com.sas.iom.SAS.IWorkspaceHelper;

import com.sas.iom.SAS.ILanguageService;

import com.sas.iom.SAS.ILanguageServicePackage.CarriageControlSeqHolder;

import com.sas.iom.SAS.ILanguageServicePackage.LineTypeSeqHolder;

import com.sas.iom.SASIOMDefs.GenericError;

import com.sas.iom.SASIOMDefs.StringSeqHolder;

import javax.swing.JOptionPane;

public class IOMTest{

public IOMTest() throws ConnectionFactoryException, GenericError

{

// connection parameters

String classID = Server.CLSID_SAS;

String host = "hunding";

int port = 8591;

String userName = "sassrv";

String password = "sasuser";

// identify the IOM Bridge server (the Workspace server)

Server server = new BridgeServer(classID,host,port);

// make a manual connection factory configuration to the server

ConnectionFactoryConfiguration cxfConfig =

new ManualConnectionFactoryConfiguration(server);

// get a connection factory manager

ConnectionFactoryManager cxfManager =

new ConnectionFactoryManager();

// get a connection factory interface from the manager

ConnectionFactoryInterface cxf = cxfManager.getFactory(cxfConfig);

// get a connection from the interface

ConnectionInterface cx = cxf.getConnection(userName,password);

// create a workspace by "narrowing" the connection to the ORB

IWorkspace iWorkspace = IWorkspaceHelper.narrow( cx.getObject() );

// Submit batch SAS code

ILanguageService sasLanguage = iWorkspace.LanguageService();

sasLanguage.Submit("%include 'c:\\temp\\IOMtest.sas'; run;");

// flush log file to string array

StringSeqHolder logHldr = new StringSeqHolder();

sasLanguage.FlushLogLines(

Integer.MAX_VALUE,

new CarriageControlSeqHolder(),

16

new LineTypeSeqHolder(),

logHldr);

// display log file

String[] logLines = logHldr.value;

JOptionPane.showMessageDialog(null, logLines);

// flush list file to string array

StringSeqHolder listHldr = new StringSeqHolder();

sasLanguage.FlushListLines(

Integer.MAX_VALUE,

new CarriageControlSeqHolder(),

new LineTypeSeqHolder(),

listHldr);

// display list file

String[] listLines = listHldr.value;

JOptionPane.showMessageDialog(null, listLines);

iWorkspace.Close();

cx.close();

}

public static void main(String args[]) {

try {

new IOMTest();

System.exit(0);

}

catch(Exception ex) {

ex.printStackTrace();

System.exit(1);

}

}

}

详情参考下面链接

· SAS OnlineDoc (includes links to all the separate product documentation).

<http://support.sas.com/91doc/docMainpage.jsp>

· SAS Integration Technologies: Version 9 Documentation.

<http://support.sas.com/rnd/itech/library/library9.html.>

· SAS Integration Technologies: Release 8.2 Documentation.

<http://support.sas.com/rnd/itech/library/library82.html>

· SAS 9.1 Open Metadata Architecture: Best Practices Guide.

<http://support.sas.com/rnd/eai/openmeta/v9/bestpractices/>

· SAS 9.1.2 Metadata Server: Setup Guide. <http://support.sas.com/rnd/eai/openmeta/v9/setup/>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有