HTTP Client 调用 ODI Scenario
来源:互联网 发布:淘宝店铺logo在线生成 编辑:程序博客网 时间:2024/06/13 05:27
HTTP-Client的官方实例如下:
http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/FormLoginDemo.java?revision=604567&view=markup
ODI官方文档中推荐HTTP URL方式调用Scenario
部分描述:
With the Metadata Navigator module, it is possible to launch a scenario from a web page or an
HTTP URL.
Note: To execute a scenario this way, you must first Install Metadata Navigator.
Principles
Metadata Navigator provides a StartScen servlet that responds to HTTP POST requests. This
servlet provides the same features as the OdiStartScen tool.
The StartScen servlet is called by using an HTTP POST request on the /snpsrepexp/startscen.do resource of your Metadata Navigator Server. Appropriate
HTTP URL.
Note: To execute a scenario this way, you must first Install Metadata Navigator.
Principles
Metadata Navigator provides a StartScen servlet that responds to HTTP POST requests. This
servlet provides the same features as the OdiStartScen tool.
The StartScen servlet is called by using an HTTP POST request on the /snpsrepexp/startscen.do resource of your Metadata Navigator Server. Appropriate
HTTP parameters should be passed with the request.
The servlet returns an HTTP response in XML, HTML or plain text format.
The servlet returns an HTTP response in XML, HTML or plain text format.
The scenario execution returns a SOAP response as shown below:
<odi:invokeScenarioResponse xmlns:odi="xmlns.oracle.com/odi/OdiInvoke">
<odi:CommandResultType>
<odi:Ok>true</odi:Ok>
<odi:SessionNumber>1148001</odi:SessionNumber>
</odi:CommandResultType>
</odi:invokeScenarioResponse>
<odi:invokeScenarioResponse xmlns:odi="xmlns.oracle.com/odi/OdiInvoke">
<odi:CommandResultType>
<odi:Ok>true</odi:Ok>
<odi:SessionNumber>1148001</odi:SessionNumber>
</odi:CommandResultType>
</odi:invokeScenarioResponse>
1、安装Metadata Navigator(参考Metadata Navigator安装及应用)
2、配置ODI Agent(参考ODI Scenario Scheduler Agent执行中的Agent配置文件设置->odiparams.bat设置)非必须
3、在ODI项目中创建Scenario(参考Running Scenario Using Variable)
4、创建JAVA应用
注:若oracledimn.war部署在远程服务器上,则
LOGON_SIT 与 LOGON_PORT需要改成对应的 IP 与 端口号
NameValuePair agentName = new NameValuePair("agent_name", "127.0.0.1");需要改成Agent所在机器的IP<如10.243.40.72>
创建ODIHttpWebService.java
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.httpclient.methods.*;
public class ODIHttpWebservice {
static final String LOGON_SITE = "localhost";
static final int LOGON_PORT = 9090;
public ODIHttpWebservice() {
super();
}
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http");
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
PostMethod authpost = new PostMethod("/oracledimn/startscen.do");
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.httpclient.methods.*;
public class ODIHttpWebservice {
static final String LOGON_SITE = "localhost";
static final int LOGON_PORT = 9090;
public ODIHttpWebservice() {
super();
}
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http");
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
PostMethod authpost = new PostMethod("/oracledimn/startscen.do");
// Prepare execute parameters(参数设置参照Oracle Data Integrator User's Guide/86)
NameValuePair agentName = new NameValuePair("agent_name", "127.0.0.1");
NameValuePair agentPort = new NameValuePair("agent_port", "20910");
NameValuePair masterDriver = new NameValuePair("master_driver","oracle.jdbc.driver.OracleDriver");
NameValuePair masterUrl = new NameValuePair("master_url", "jdbc:oracle:thin:@10.244.155.16:1521:ora10g");
NameValuePair masterUser = new NameValuePair("master_user", "EXTFWK");
NameValuePair masterPsw = new NameValuePair("master_psw", "cByXdik4DDOzPIqHygsc5Wp");
NameValuePair workRepository = new NameValuePair("work_repository", "EASAS WORK01");
NameValuePair snpsUser = new NameValuePair("snps_user", "SUPERVISOR");
NameValuePair snpsPsw = new NameValuePair("snps_psw", "fDyXwp0FX38Lh7SljxUs");
NameValuePair scenName = new NameValuePair("scen_name", "LOAD_ROLE_FUNCTIONS");
NameValuePair scenVersion = new NameValuePair("scen_version", "001");
NameValuePair contextCode = new NameValuePair("context_code", "GLOBAL");
NameValuePair logLevel = new NameValuePair("log_level", "2");
NameValuePair httpReply = new NameValuePair("http_reply", "XML");
//Add Project's Variable by using project code
NameValuePair projectParam1 = new NameValuePair("EASAS_PROJECT.roleCode", "'USER_MANAGE'");
authpost.setRequestBody(
new NameValuePair[] { agentName, agentPort, masterDriver, masterUrl,
masterUser, masterPsw, workRepository, snpsUser, snpsPsw, scenName,
scenVersion, contextCode, logLevel, httpReply, projectParam1});
NameValuePair agentPort = new NameValuePair("agent_port", "20910");
NameValuePair masterDriver = new NameValuePair("master_driver","oracle.jdbc.driver.OracleDriver");
NameValuePair masterUrl = new NameValuePair("master_url", "jdbc:oracle:thin:@10.244.155.16:1521:ora10g");
NameValuePair masterUser = new NameValuePair("master_user", "EXTFWK");
NameValuePair masterPsw = new NameValuePair("master_psw", "cByXdik4DDOzPIqHygsc5Wp");
NameValuePair workRepository = new NameValuePair("work_repository", "EASAS WORK01");
NameValuePair snpsUser = new NameValuePair("snps_user", "SUPERVISOR");
NameValuePair snpsPsw = new NameValuePair("snps_psw", "fDyXwp0FX38Lh7SljxUs");
NameValuePair scenName = new NameValuePair("scen_name", "LOAD_ROLE_FUNCTIONS");
NameValuePair scenVersion = new NameValuePair("scen_version", "001");
NameValuePair contextCode = new NameValuePair("context_code", "GLOBAL");
NameValuePair logLevel = new NameValuePair("log_level", "2");
NameValuePair httpReply = new NameValuePair("http_reply", "XML");
//Add Project's Variable by using project code
NameValuePair projectParam1 = new NameValuePair("EASAS_PROJECT.roleCode", "'USER_MANAGE'");
authpost.setRequestBody(
new NameValuePair[] { agentName, agentPort, masterDriver, masterUrl,
masterUser, masterPsw, workRepository, snpsUser, snpsPsw, scenName,
scenVersion, contextCode, logLevel, httpReply, projectParam1});
client.executeMethod(authpost);
System.out.println("Project Param1: "+projectParam1.getValue()+" /nLogin form post: " + authpost.getResponseBodyAsString().toString());
System.out.println("Project Param1: "+projectParam1.getValue()+" /nLogin form post: " + authpost.getResponseBodyAsString().toString());
// release any connection resources used by the method
authpost.releaseConnection();
}
}
}
}
5、启动Tomcat,确认Metadata Navigator应用正常
6、调用ODI Agent,确认Agent正常使用
7、运行JAVA应用,执行正常将在控制台得到输出信息,输出信息类似以下结构:
<odi:invokeScenarioResponse xmlns:odi="xmlns.oracle.com/odi/OdiInvoke">
<odi:CommandResultType>
<odi:Ok>true</odi:Ok>
<odi:SessionNumber>1148001</odi:SessionNumber>
</odi:CommandResultType>
</odi:invokeScenarioResponse>
<odi:CommandResultType>
<odi:Ok>true</odi:Ok>
<odi:SessionNumber>1148001</odi:SessionNumber>
</odi:CommandResultType>
</odi:invokeScenarioResponse>
8、到ODI中检查会话是否正常执行,检查参数传递是否生效
- HTTP Client 调用 ODI Scenario
- ODI调用WebService---->OdiInvokeWebService
- OS Command 调用 ODI Senario
- WebService调用ODI同步任务
- ODI
- Http Client
- http-client
- http client
- HTTP Client
- HTTP Client
- Http client
- HTTP Client
- 通过webservice调用ODI方案的实现方式
- go http client, http server
- Client HTTP Programming Primer
- Http Client Protocol Issues
- HTTP Client 编写
- Android Asynchronous Http Client
- JAVA 小写金额转换大写金额
- jquery flexigrid checkbox翻页后保存原选项
- lucene 索引非txt文档 (pdf word rtf html xml)
- MTK的高亮机制
- 对eclipse功能的一些扩展方式
- HTTP Client 调用 ODI Scenario
- java调用oracle存储过程
- 比较 Java 数据对象和 EJB 技术
- SDRAM工作原理及S3C2410 SDRAM控制器配置方法
- ServiceSelectionNavigation一行显示六个块的滑动效果
- C#引用类型
- webservice安全性浅谈
- IEEE 802.11n协议中的相关技术
- 自制批处理使用Yui Compressor压缩并打包js或css文件