Vous êtes sur la page 1sur 11

Calling webservice through pl/sql

procedure
(xxiris_om_common_soapui_k)

Author:
Sonia Kamra
11/24/2009
It has three main steps:

1. Create Request
2. Add Parameters
3. Invoke the webservice to get the
response
Step1:Creating a request
FUNCTION new_request
(method IN VARCHAR2,
submethod IN VARCHAR2,
namespace IN VARCHAR2)
RETURN request;
• Example
g_namespace VARCHAR2(500):= 'http://uhg.iris.service/types/';
x_req xxiris_om_common_soapui_k.request;

x_request:= xxiris_om_common_soapui_k.new_request
('TrustCommerceRequest',
'customerData',
'xmlns="' || g_namespace || '"'
);
Step 2: Add Parameters
PROCEDURE add_parameter( req IN OUT NOCOPY request,
name IN VARCHAR2,
type IN VARCHAR2,
value IN VARCHAR2);
Example:
xxxiris_om_common_soapui_k.ADD_PARAMETER (x_request,
'transactionId',
'xsd:string',
‘12345'
);

At this point we add all the parameters in the order how its mentioned in WSDL.
Step 3: Invoke
FUNCTION invoke (
req IN OUT NOCOPY request,
url IN VARCHAR2,
action IN VARCHAR2
)
RETURN response
Example:
• x_resp xxxiris_om_common_soapui_k.response;

x_resp :=
xxxiris_om_common_soapui_k.invoke (x_req,
http://apsp9040.uhc.com:7784/TrustCommerce/TrustCommerceWSSoapHttpPort?wsdl’,
'http://uhg.iris.service//performAction'
);
Sample Code

DECLARE
x_request xxiris_om_common_soapui_k.request;
x_resp xxiris_om_common_soapui_k.response;
g_namespace VARCHAR2 (500) := 'http://uhg.iris .service/types/';
buf VARCHAR2 (32767);
BEGIN
x_request :=
xxiris_om_common_soapui_k.new_request ('TrustCommerceRequest', 'customerData','xmlns="' || g_namespace || '"');

xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'transactionId','xsd:string', '');


xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'action','xsd:string','verify');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request, 'avs', 'xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'cardName','xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'cardNumber','xsd:string','4111111111111111');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'cardBrand','xsd:string','VISA');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'message','xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'status','xsd:string',);
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'address1','xsd:string','1);
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'amount','xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'keyId','xsd:string','12345');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'result','xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'state','xsd:string','');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'zip','xsd:string','920001');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'expDate','xsd:string','1215');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'city','xsd:string','Somewhere');
xxiris_om_common_soapui_k.ADD_PARAMETER (x_request,'billingId','xsd:string','');
x_resp :=
xxiris_om_common_soapui_k.invoke
(x_request,
vg_ws_address,
'http://uhg.iris.service//performAction'
);
END;
Request sent

- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Body>
- <TrustCommerceRequest xmlns="http://uhg.iris.service/types/">
- <customerData>
<transactionId xsi:type="xsd:string" />
<action xsi:type="xsd:string">verify</action>
<avs xsi:type="xsd:string" />
<cardName xsi:type="xsd:string">Raj</cardName>
<cardNumber xsi:type="xsd:string">4111111111111111</cardNumber>
<cardBrand xsi:type="xsd:string">VISA</cardBrand>
<message xsi:type="xsd:string" />
<status xsi:type="xsd:string" />
<address1 xsi:type="xsd:string">123 Test St.</address1>
<instrID xsi:type="xsd:string" />
<amount xsi:type="xsd:string" />
<keyid xsi:type="xsd:string">12345</keyid>
<result xsi:type="xsd:string" />
<state xsi:type="xsd:string" />
<zip xsi:type="xsd:string" />
<expDate xsi:type="xsd:string">1215</expDate>
<city xsi:type="xsd:string">Somewhere</city>
<billingId xsi:type="xsd:string" />
</customerData>
</TrustCommerceRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response Received

<TrustCommerceResponse>
<Result>
<transactionId>024-0073107562</transactionId>
<action nil="1"/>
<avs nil="1"/>
<cardName nil="1"/>
<cardNumber nil="1"/>
<cardBrand nil="1"/>
<message> - avs: A</message>
<media>cc</media>
<status>approved</status>
<address1 nil="1"/>
<instrID nil="1"/>
<amount nil="1"/>
<keyId>12345</keyId>
<result nil="1"/>
<state nil="1"/>
<zip nil="1"/>
<expDate nil="1"/>
<city nil="1"/>
<billingId nil="1"/>
</Result>
</TrustCommerceResponse>