-
PROCEDURE call_web_service(x_return_status OUT NOCOPY VARCHAR2,
-
x_msg_count OUT NOCOPY NUMBER,
-
x_msg_data OUT NOCOPY VARCHAR2,
-
p_enent_rec IN cux_pub_push_iface_dtls%ROWTYPE,
-
x_request_xmltype OUT NOCOPY sys.xmltype,
-
x_response_xmltype OUT NOCOPY sys.xmltype) IS
-
l_api_name CONSTANT VARCHAR2(30) := ‘call_web_service‘;
-
l_savepoint_name CONSTANT VARCHAR2(30) := ‘SP01_call_ws‘;
-
-
l_soap_content CLOB := ‘<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.common.qiku.kmss.landray.com/">
-
-
-
-- l_soap_content VARCHAR2(32767);
-
-
-
-
l_http_resp utl_http.resp;
-
l_soap_respond VARCHAR2(32767);
-
-
-
l_doc dbms_xmldom.domdocument;
-
l_docelem dbms_xmldom.domelement;
-
l_nodelist dbms_xmldom.domnodelist;
-
-
-
-
-
-
l_err_msg VARCHAR2(3000);
-
l_webservice_url VARCHAR2(3000);
-
-
SELECT pla.po_line_id, --行id
-
-
-
pv.vendor_name, --供应商名称--
-
pv.segment1 vendor_code, --供应商简码--
-
-
(SELECT ppf.employee_number
-
-
WHERE ppf.person_id = pha.agent_id
-
AND rownum = 1) agent_name, --采购员名称
-
-
atv.name term_name, --付款条件--
-
pha.segment1 po_number, --po号--
-
pha.revision_num, --版本号--
-
-
-
msib.segment1 item_code, --物料编码--
-
msib.description item_desc, --物料名称--
-
-
pla.unit_price no_tax_unit_price, --未含税单价--
-
NULL tax_unit_price, --含税单价--
-
nvl((SELECT MAX(a.tax_rate) / 100
-
-
po_line_locations_all pll
-
WHERE a.application_id = 201
-
AND a.entity_code = ‘PURCHASE_ORDER‘
-
AND a.event_class_code = ‘PO_PA‘
-
AND a.trx_id = pll.po_header_id
-
AND a.trx_line_id = pll.line_location_id
-
AND pll.po_line_id = pla.po_line_id
-
AND a.tax_rate IS NOT NULL
-
-
-
AND (nvl(pll.cancel_flag,
-
‘N‘) = ‘Y‘ OR nvl(a.cancel_flag,
-
-
-
-
pla.quantity * pla.unit_price no_tax_total_amount, --未含税总额--
-
NULL tax_total_amount, --含税总金额--
-
pha.currency_code, --币种--
-
-
-
-
‘yyyy-mm-dd‘) rate_date, --汇率日期--
-
-
(SELECT nvl(ppf.FULL_NAME,fu.user_name)
-
-
-
WHERE fu.employee_id = ppf.person_id(+)
-
AND fu.user_id = pha.created_by
-
AND rownum = 1) creator, --创建人--
-
-
‘yyyy-mm-dd‘) create_date, --创建时间--
-
decode(nvl(pla.cancel_flag,
-
-
-
-
decode(nvl(pha.cancel_flag,
-
-
-
-
decode(nvl(pha.authorization_status,
-
-
-
-
‘0‘))) syn_status, --状态--
-
pha.comments remark --备注--
-
-
-
-
-
-
-
financials_system_params_all fspa
-
WHERE pha.po_header_id = pla.po_header_id
-
AND pha.org_id = hou.organization_id
-
AND pha.vendor_id = pv.vendor_id
-
AND atv.term_id = pha.terms_id
-
AND fspa.org_id = pha.org_id
-
AND pla.item_id = msib.inventory_item_id
-
AND fspa.inventory_organization_id = msib.organization_id
-
AND pha.po_header_id = get_number_from_varchar2(p_enent_rec.key_value1);
-
-
--l_webservice_url VARCHAR2(3000);
-
l_sec_content VARCHAR2(20000);
-
l_param_content VARCHAR2(20000);
-
l_warehouseid VARCHAR2(2000);
-
-
l_returncode VARCHAR2(2000);
-
l_returndesc VARCHAR2(2000);
-
-
l_resultinfo VARCHAR2(2000);
-
-
l_put_flag VARCHAR2(1) := ‘N‘;
-
-
-
l_req_txt_tbl dbms_sql.varchar2_table;
-
-
l_round_flag varchar2(10);
-
-
-
-- start activity to create savepoint, check compatibility
-
-- and initialize message list, include debug message hint to enter api
-
x_return_status := hss_api.start_activity(p_pkg_name => g_pkg_name,
-
p_api_name => l_api_name,
-
p_savepoint_name => l_savepoint_name,
-
p_init_msg_list => fnd_api.g_false);
-
raise_exception(x_return_status);
-
-
-
-
-
-
-
-
SELECT MAX(def.addition_info)
-
-
FROM cux_00_imp_iface_system_def def
-
WHERE def.system_code = p_enent_rec.system_code;
-
-
--0.判断库存组织是否满足同步条件,不满足则退出执行
-
-
-
--1.根据iface_system_code获取web服务地址
-
-
-
-
-
get_imis_sec_info(p_iface_system_code => p_enent_rec.system_code,
-
x_sec_content => l_sec_content);
-
-
-
-
-
-
-
-
l_soap_content := l_soap_content || l_sec_content;
-
-
l_soap_content := l_soap_content || ‘ <soapenv:Body>
-
-
-
select max(get_round_flag(pha.org_id)) into l_round_flag from po_headers_all pha
-
where pha.po_header_id = get_number_from_varchar2(p_enent_rec.key_value1);
-
-
--4.按照业务需求获取单据信息并安装WS的要求封装报文
-
-- l_soap_content := l_soap_content || output_xml(‘<poInfo>‘);
-
FOR rec_doc_info IN cs_info
-
-
l_soap_content := l_soap_content || ‘
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.name,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.create_date,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.currency_code,
-
-
-
l_soap_content := l_soap_content || output_xml( rec_doc_info.creator ,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.rate,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.rate_date,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.po_line_id,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.is_invoice,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.item_code,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.item_desc,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.no_tax_unit_price,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.quantity,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.line_num,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.po_line_id,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.po_number,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.revision_num,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.term_name,
-
-
-
l_soap_content := l_soap_content || output_xml( rec_doc_info.agent_name ,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.remark,
-
-
-
l_soap_content := l_soap_content || output_xml(NULL,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.vendor_code,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.vendor_name,
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.syn_status,
-
-
-
IF NVL(l_round_flag,‘N‘)=‘Y‘ THEN
-
l_soap_content := l_soap_content || output_xml(round(rec_doc_info.no_tax_unit_price * (1 + nvl(rec_doc_info.tax_rate,
-
-
-
-
l_soap_content := l_soap_content || output_xml(round(rec_doc_info.no_tax_unit_price * (1 + nvl(rec_doc_info.tax_rate,
-
-
-
-
-
-
l_soap_content := l_soap_content || output_xml(rec_doc_info.tax_rate,
-
-
-
IF NVL(l_round_flag,‘N‘)=‘Y‘ THEN
-
l_soap_content := l_soap_content || output_xml(round(round(rec_doc_info.no_tax_unit_price * (1 + nvl(rec_doc_info.tax_rate,
-
0)),2) * rec_doc_info.quantity,2),
-
-
-
l_soap_content := l_soap_content || output_xml(round(round(rec_doc_info.no_tax_unit_price * (1 + nvl(rec_doc_info.tax_rate,
-
0)),6) * rec_doc_info.quantity,2),
-
-
-
l_soap_content := l_soap_content || ‘
-
-
-
-
-
-
-
-
-
-
l_soap_content := l_soap_content || output_xml(‘ </ser:getOrderInfo>
-
-
-
-- DBMS_OUTPUT.put_line(l_soap_content);
-
-
-
l_soap_request := l_soap_content;
-
x_request_xmltype := xmltype.createxml(l_soap_request);
-
-
-
-
-
-
-
-
cux_pub_common_utl.get_clob2varchartbl(p_clob => l_soap_request,
-
x_varchartbl => l_req_txt_tbl,
-
-
l_http_req := utl_http.begin_request(l_webservice_url,
-
-
sys.utl_http.http_version_1_1);
-
-
utl_http.set_header(l_http_req,
-
-
‘text/xml;charset=utf-8‘);
-
-
utl_http.set_header(l_http_req,
-
-
-
utl_http.set_header(l_http_req,
-
-
-
-
-
-
-
IF l_req_txt_tbl.count > 0 THEN
-
FOR i IN l_req_txt_tbl.first .. l_req_txt_tbl.last
-
-
-
utl_http.write_text(l_http_req,
-
-
-
-
-
-
-
-
l_http_resp := utl_http.get_response(l_http_req);
-
utl_http.read_text(l_http_resp,
-
-
utl_http.end_response(l_http_resp);
-
-- utl_http.end_request(l_http_req);
-
l_resp_xml := xmltype.createxml(l_soap_respond);
-
x_response_xmltype := l_resp_xml;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
SELECT xmltype(l_soap_respond).extract(‘//return/child::text()‘).getstringval()
-
-
-
-
-
-
-
-
-
-
-
hss_api.set_message(p_app_name => ‘CUX‘,
-
p_msg_name => ‘CUX_WIP_CALL_PATS_WS_FAIL‘,
-
-
p_token1_value => l_returncode || ‘-‘ || l_returndesc || ‘-‘ || l_resultinfo);
-
x_return_status := fnd_api.g_ret_sts_error;
-
raise_exception(x_return_status);
-
-
update_po_hearder(get_number_from_varchar2(p_enent_rec.key_value1));
-
-
-
--11.调用成功则更新PO订单的attribute15为Y
-
-
-
-
-
-
-- end activity, include debug message hint to exit api
-
x_return_status := hss_api.end_activity(p_pkg_name => g_pkg_name,
-
p_api_name => l_api_name,
-
p_commit => fnd_api.g_false,
-
x_msg_count => x_msg_count,
-
x_msg_data => x_msg_data);
-
-
WHEN fnd_api.g_exc_error THEN
-
-
utl_http.end_response(l_http_resp);
-
-
-
-
-
x_return_status := hss_api.handle_exceptions(p_pkg_name => g_pkg_name,
-
p_api_name => l_api_name,
-
p_savepoint_name => l_savepoint_name,
-
p_exc_name => hss_api.g_exc_name_error,
-
x_msg_count => x_msg_count,
-
x_msg_data => x_msg_data);
-
WHEN fnd_api.g_exc_unexpected_error THEN
-
-
utl_http.end_response(l_http_resp);
-
-
-
-
-
x_return_status := hss_api.handle_exceptions(p_pkg_name => g_pkg_name,
-
p_api_name => l_api_name,
-
p_savepoint_name => l_savepoint_name,
-
p_exc_name => hss_api.g_exc_name_unexp,
-
x_msg_count => x_msg_count,
-
x_msg_data => x_msg_data);
-
-
-
utl_http.end_response(l_http_resp);
-
-
-
-
-
x_return_status := hss_api.handle_exceptions(p_pkg_name => g_pkg_name,
-
p_api_name => l_api_name,
-
p_savepoint_name => l_savepoint_name,
-
p_exc_name => hss_api.g_exc_name_others,
-
x_msg_count => x_msg_count,
-
x_msg_data => x_msg_data);
-
ORACLE EBS WebService推送报文例子 XML格式