%PARAMETER_NAME%
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>%NAME%</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
<m:StockName>%NAME%</m:StockName>
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>%NAME%</m:StockName> <m:StockCount>%COUNT%</m:StockCount> </m:GetStockPrice> </soap:Body> </soap:Envelope>
NAME
and COUNT
<m:StockName>%NAME%</m:StockName> <m:StockCount>%COUNT%</m:StockCount>
PARAMETER_NAME_1={VALUE_1}|PARAMETER_NAME_2={VALUE_2}|…PARAMETER_NAME_N={VALUE_N}
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
/soap:Envelope/soap:Body/m:GetStockPriceResponse
<m:Price>34.5</m:Price>
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
RESULT_PRICE={m:Price}
m:Price
value to the Response obtained from SOAP / XML. Further on the example it will be considered in more detail. <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>%NAME%</m:StockName> <m:StockCount>%COUNT%</m:StockCount> </m:GetStockPrice> </soap:Body> </soap:Envelope>
xmlns
from this query. From this example, you need to fill it with the following value:xmlns:soap="http://www.w3.org/2001/12/soap-envelope" xmlns:m="http://www.example.org/stock"
create or replace package WS is PROCEDURE add_param(pi_params in out varchar2, pi_parameter_name varchar2, pi_parameter_value varchar2); FUNCTION get_param(pi_params varchar2, pi_parameter_name varchar2) return varchar2; PROCEDURE call(pi_template_id VARCHAR2, pi_params VARCHAR2, po_params OUT VARCHAR2, po_data_response OUT VARCHAR2); end WS;
http://10.10.1.100:8080/GoodsManagementWS/Goods
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:GetInfo> <m:ID>1</m:ID> </m: GetInfo > </soap:Body> </soap:Envelope>
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:Response> <m:Name>Printer</m:Name> <m:Vendor>HP</m:Vendor> <m:Price>Printer</m:Price> <m:Count>Printer</m:Count> </m:Response> </soap:Body> </soap:Envelope>
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:Add> <m:Name>Printer</m:Name> <m:Vendor>HP</m:Vendor> <m:Price>Printer</m:Price> <m:Count>Printer</m:Count> </m: Add > </soap:Body> </soap:Envelope>
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:Response> <m:id>1</m:id> </m:Response> </soap:Body> </soap:Envelope>
INSERT INTO WS_SERVER (SERVER_ID, URL, STATUS) VALUES ('Store', 'http://10.10.1.100:8080/GoodsManagementWS/Goods', 1);
WS_TEMPLATE
INSERT INTO WS_TEMPLATE (TEMPLATE_ID, TEMPLATE_XML, SERVER_ID, REQUEST_PARAMS, RESPONSE_PARAMS, XMLNS, PATH, STATUS) VALUES ('GetInfo', --TEMPLATE_ID '<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:GetInfo> <m:ID>%ID%</m:ID> </m: GetInfo > </soap:Body> </soap:Envelope> ', --TEMPLATE_XML 'Store', --SERVER_ID NULL, --REQUEST_PARAMS 'NAME={m:Name}|VENDOR={m:Vendor}|PRICE={m:Price}|COUNT={m:Count}', --RESPONSE_PARAMS 'xmlns:soap="http://www.w3.org/2001/12/soap-envelope" xmlns:m="http://www.example.org/goods"', --XMLNS '/soap:Envelope/soap:Body/m:Response', --PATH 1) ;--STATUS
INSERT INTO WS_TEMPLATE (TEMPLATE_ID, TEMPLATE_XML, SERVER_ID, REQUEST_PARAMS, RESPONSE_PARAMS, XMLNS, PATH, STATUS) VALUES ('AddInfo', --TEMPLATE_ID '<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:Add> <m:Name>%NAME%</m:Name> <m:Vendor>%VENDOR%</m:Vendor> <m:Price>%PRICE%</m:Price> <m:Count>%COUNT%</m:Count> </m: Add > </soap:Body> </soap:Envelope> ', --TEMPLATE_XML 'Store', --SERVER_ID NULL, --REQUEST_PARAMS 'ID={m:id}', --RESPONSE_PARAMS 'xmlns:soap="http://www.w3.org/2001/12/soap-envelope" xmlns:m="http://www.example.org/goods"', --XMLNS '/soap:Envelope/soap:Body/m:Response', --PATH 1); --STATUS
CREATE OR REPLACE PROCEDURE GET_INFO(PI_ID VARCHAR2, PO_NAME OUT VARCHAR2, PO_VENDOR OUT VARCHAR2, PO_PRICE OUT NUMBER, PO_COUNT OUT NUMBER) IS v_template_id VARCHAR2(100) := 'GetInfo'; v_data_response VARCHAR2(4000); v_request_params VARCHAR2(4000); v_response_params VARCHAR2(4000); BEGIN -- -- ws.add_param(v_request_params, 'ID', PI_ID); -- -- ws.call(v_template_id, v_request_params, v_response_params, v_data_response); -- -- PO_NAME := ws.get_param(v_response_params, 'NAME'); PO_VENDOR := ws.get_param(v_response_params, 'VENDOR'); PO_PRICE := ws.get_param(v_response_params, 'PRICE'); PO_COUNT := ws.get_param(v_response_params, 'COUNT'); END;
PROCEDURE ADD_INFO(PI_NAME VARCHAR2, PI_VENDOR VARCHAR2, PI_PRICE NUMBER, PI_COUNT NUMBER, PO_ID OUT VARCHAR2) IS v_template_id VARCHAR2(100) := 'AddInfo'; v_data_response VARCHAR2(4000); v_request_params VARCHAR2(4000); v_response_params VARCHAR2(4000); BEGIN -- -- ws.add_param(v_request_params, 'NAME', PI_NAME); ws.add_param(v_request_params, 'VENDOR', PI_VENDOR); ws.add_param(v_request_params, 'PRICE', PI_PRICE); ws.add_param(v_request_params, 'COUNT', PI_COUNT); -- -- ws.call(v_template_id, v_request_params, v_response_params, v_data_response); -- -- PO_ID := ws.get_param(v_response_params, 'ID'); END;
WS_LOG
table WS_LOG
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/goods"> <m:Response1> <m:id>1</m:id> </m:Response1> <m:Response2> <m:id>1</m:id> </m:Response2> <m:Response3> <m:id>1</m:id> </m:Response3> </soap:Body> </soap:Envelope>
/soap:Envelope/soap:Body
. Since the necessary answer lies between the <soap:Body> </soap:Body>
tags. And already RESPONSE_PARAMS will need to be written a little more detailed.ID1={m:Response1/m:id}|ID2={m:Response2/m:id}|ID3={m:Response3/m:id}
<Request> <Data>Test</Data> </Request>
<Response> <Result>DONE</Result> <Response>
Response
and RESPONSE_PARAMS is RES={Result}
. I note that the variable name is specified arbitrarily, but it will be used for the query in the get_param get_param
Source: https://habr.com/ru/post/223405/
All Articles