使用DB2內建的SOAP UDF實現業務通知

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   os   使用   sp   

DB2內建了WebService用戶端的實現,具體命令如下:

啟用命令:

db2enable_soap_udf -n dbName -u uID -p password [-force]
The parameters have the following definitions:
dbName - The database name to be enabled
uID user - ID for accessing the database
password - The password associated with the user ID
-force - Attempts to drop any existing functions.

如:db2enable_soap_udf -n MS_TRD -u zjyw -p 123456

啟用成功後,可調用以下API介面:

db2xml.soaphttpv (VARCHAR(256), VARCHAR(256), VARCHAR(3072))
db2xml.soaphttpv (VARCHAR(256), VARCHAR(256), CLOB(1M))
db2xml.soaphttpc (VARCHAR(256), VARCHAR(256), varchar(3072))
db2xml.soaphttpc (VARCHAR(256), VARCHAR(256), CLOB(1M))
db2xml.soaphttpcl ( VARCHAR(256), VARCHAR(256), varchar(3072))

停用命令:

db2disable_soap_udf -n dbName -u uID -p password

調用步驟:

1、測試webService用戶端與服務端的連通性

建立test.sql,編寫如下代碼:

 

connect to MS_TRD;VALUES db2xml.soaphttpc(‘http://191.168.0.209:8080/SHCH/services/shch‘,‘http://191.168.0.209:8080/SHCH/services/shch.shchHttpEndpoint/‘,varchar (‘<SendMessage xmlns="http://axis2.shch.xtp.xquant.com"><action>81</action><requestXml>12345</requestXml></SendMessage>‘));

 在DB2命令視窗中執行:db2 -tvf d:\test.sql

成功調用後,就可以繼續寫DB2函數供預存程序或者觸發器調用了

2、建立表TTRD_UDF,具體見使用 DB2 觸發器和Java UDF實現業務通知

 

3、新增10000條測試資料

begin atomic  declare v_cnt int; set v_cnt=0; while (v_cnt<10000) do  insert into TTRD_UDF(CODE, NAME, REMARK) values (rtrim(char(v_cnt+100000)),‘test‘, ‘-‘); set v_cnt=v_cnt+1; end while;end

 

4、建立DB2函數

CREATE FUNCTION zjyw.SENDMESSAGE2 (symbol VARCHAR(100))RETURNS VARCHAR(1000)LANGUAGE SQL CONTAINS SQLEXTERNAL ACTION NOT DETERMINISTICRETURNVALUES db2xml.soaphttpc(‘http://191.168.0.209:8080/SHCH/services/shch‘,‘http://191.168.0.209:8080/SHCH/services/shch.shchHttpEndpoint/‘,varchar (‘<SendMessage xmlns="http://axis2.shch.xtp.xquant.com"><action>81</action><requestXml>‘|| + symbol + ||‘</requestXml></SendMessage>‘ ) ) )

5、建立TTRD_UDF觸發器

CREATE TRIGGER ZJYW.AFTER_UPDATE_UFTAFTER UPDATE OF NAME ON ZJYW.TTRD_UDFREFERENCING OLD AS OLDROW NEW AS NEWROWFOR EACH ROW MODE DB2SQLBEGIN ATOMICIF(NEWROW.NAME<>‘‘)THENVALUES(SENDMESSAGE2(OLDROW.CODE));END IF;END;

6、測試批量修改10000條資料效能

update zjyw.TTRD_UDF set NAME=‘TEST2‘

全部執行完成耗時36分17秒,效能很一般。

如果WebService服務端未開啟時,觸發器會逾時等待,實用性比較差。

使用DB2內建的SOAP UDF實現業務通知

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.