首页 > 其他分享 >HTTP Client 调用 ODI Scenario

HTTP Client 调用 ODI Scenario

时间:2023-05-26 12:07:14浏览次数:46  
标签:HTTP NameValuePair ODI Client new Navigator Metadata


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 parameters should be passed with the request.
 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>


 


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"); 
 

    

 

           // 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}); 
 

    

 

              client.executeMethod(authpost);         
 
         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>

 


8、到ODI中检查会话是否正常执行,检查参数传递是否生效



 

标签:HTTP,NameValuePair,ODI,Client,new,Navigator,Metadata
From: https://blog.51cto.com/u_16129500/6354777

相关文章

  • ODI CDC应用猜想
    注:本文内容猜想属于个人意见,不保证内容的正确性。如有错误,欢迎指正。 1、Package中Model的选项设置为JournalizingModel此配置无法正常完成cdc数据捕获)参数选择AddSubscriber、ExtendWindow、LockSubscriber/RemoveSubscriber、PurgeJournal、UnlockSubcrib......
  • FLEX实践—XML HttpService加载错误
    主应用代码:<?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="middle" creationComplete="init......
  • UNIX网络编程:socket & select() 实现clients/server通信
    一、问题引入UNIX网络编程卷1:套接字联网API(第三版)第6章介绍了I/O复用可以通过select()的单进程服务器与多客户端通信。UNIX下可用的5中I/O模型:阻塞式I/O非阻塞式I/OI/O(select和poll)信号驱动式I/O(SIGIO)异步I/O(POSIX的aio_系列函数)其中前面4种可以分为同步I/O,第五种为......
  • 关闭浏览器https 调用http 文件的问题
    关闭浏览器https调用http的JS文件拦截和警告会涉及到安全性问题,建议不要直接禁用。如果确实需要屏蔽提醒,可以参考以下方法:使用浏览器插件:可以安装一些浏览器插件,例如HTTPSEverywhere、DisableMixedContent等来屏蔽https调用http的js文件的拦截和警告。更改浏览器安全设置......
  • C# 操作List集合报错:集合被修改,枚举操作可能不会执行(Collection was modified, enume
    问题Ihavemultithreadsapplicationandigetthiserror**************ExceptionText**************System.InvalidOperationException:Collectionwasmodified;enumerationoperationmaynotexecute.atSystem.ThrowHelper.ThrowInvalidOperationExcepti......
  • 使用resource读取properties文件,出现Cause: java.sql.SQLException: No suitable driv
    ###Errorqueryingdatabase.Cause:java.sql.SQLException:Nosuitabledriverfoundforhttp://maven.apache.org###Theerrormayexistincom/louis/dao/UserMapper.xml###Theerrormayinvolvecom.louis.dao.UserMapper.getUserList###Theerroroccurred......
  • JAVA使用HTTP代码示例
    以下是使用Java发送HTTP请求的示例代码:```javaimportjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.net.HttpURLConnection;importjava.net.URL;publicclassHttpExample{publicstaticvoidmain(String[]args){try{//创建URL对象URLurl=newU......
  • 跟我一起探索 HTTP-HTTP 协议中的数据压缩
    数据压缩是提高Web站点性能的一种重要手段。对于有些文件来说,高达70%的压缩比率可以大大减低对于带宽的需求。随着时间的推移,压缩算法的效率也越来越高,同时也有新的压缩算法被发明出来,应用在客户端与服务器端。在实际应用时,web开发者不需要亲手实现压缩机制,浏览器及服务器都已......
  • Flask006_ HTTP 请求方法
    请求某个URL时,要获取数据,用GET方法。要删除服务器数据,用DELETE方法。要往服务器添加数据,就用POST方法。@app.route('/blog/add/post/get',methods=['POST','GET'])defblog_add_post_get():ifrequest.method=='GET':return'使用GET方......
  • HTTP协议入门
    本篇文章转载自阮一峰老师的《HTTP协议入门》,供学习使用。HTTP协议是互联网的基础协议,也是网页开发的必备知识,最新版本HTTP/2更是让它成为技术热点。本文介绍HTTP协议的历史演变和设计思路。一、HTTP/0.9HTTP是基于TCP/IP协议的应用层协议。它不涉及数据包(packet)传......