Skip to Main Content
  • Questions
  • How to create a SOA service using PL/SQL

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, sundar.

Asked: January 03, 2011 - 9:14 am UTC

Last updated: January 04, 2011 - 7:07 am UTC

Version: 8i/9i/10g

Viewed 10K+ times! This question is

You Asked

Hello Tom
Pl. explain with a simple example using PL/SQL (8i/9i/10g) exclusively not using apache/mod_sql/...etc, how to create/consume web services (like insert/update of a table).
Thanks 
sundar

and Tom said...

rather than reinventing the proverbial wheel, I'll just point you to articles that do this already

http://www.oracle-base.com/articles/9i/ConsumingWebServices9i.php

http://www.oracle-base.com/articles/10g/utl_dbws10g.php

http://www.oracle-base.com/articles/11g/NativeOracleXmlDbWebServices_11gR1.php

(in 8i, it is going to be utl_http based, left as an exercise for you based on the examples above)



Rating

  (8 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

How to create a SOA service using PL/SQL

sundar dha, January 03, 2011 - 11:35 am UTC

<code>Tom
What about dbms_epg package in 10g
</code>
Tom Kyte
January 03, 2011 - 11:47 am UTC

you wouldn't really need that - that does the OWA (oracle web agent) initialization stuff and makes it so the owa_* and htp/htf packages are ready to go.

It would let a mod_plsql client (like a web browser) retrieve a page of HTML...

How to create a SOA service using PL/SQL

sundar dha, January 03, 2011 - 11:51 am UTC

Tom
But the dbms_epg dones not require any web server to invoke.....right.

Tom Kyte
January 03, 2011 - 12:16 pm UTC

neither does XDB which predates dbms_epg and provides http to the database...

How to create a SOA service using PL/SQL

sundar dha, January 03, 2011 - 2:13 pm UTC

Thanks

PL/SQL ENDPOINT creation

sundar dha, January 03, 2011 - 2:37 pm UTC

Tom
Following t-sql code from sqlserver end point creation
DROP ENDPOINT sql_endpoint;
GO

CREATE ENDPOINT sql_endpoint 
STATE = STARTED
AS HTTP(
   PATH = '/sql', 
   AUTHENTICATION = (INTEGRATED ), 
   PORTS = ( CLEAR ), 
   SITE = 'SERVER'
   )
FOR SOAP (
   WEBMETHOD 'GetSqlInfo' 
            (name='master.dbo.xp_msver', 
             SCHEMA=STANDARD ),
   WEBMETHOD 'DayAsNumber' 
            (name='master.sys.fn_MSdayasnumber'),
   WSDL = DEFAULT,
   SCHEMA = STANDARD,
   DATABASE = 'master',
   NAMESPACE = 'http://tempUri.org/'
   ); 
GO


In the same way i would like to create a PL/SQL end-point wsdl.
Could you pl. guide me in this regard.

Tom Kyte
January 03, 2011 - 2:58 pm UTC

if you read the associated linked to documents - you'll see how to do it. I'm not in a position to write your code. As a developer you want to

a) understand how to do it
b) be able to do it
c) do it

Not have it done for you from start to finish. Don't you think you've been pointed in the right direction - with examples - so that you can reverse engineer what you did in sqlserver (you know, get the specification), and then implement in Oracle?


PL/SQL SOA service

sundar dha, January 03, 2011 - 3:05 pm UTC

Tom
Thank you for your reply, but the links you have given pointing to "How to consuming the wsdl". Where as i need info for creating the above end-points.
Thanks

Tom Kyte
January 03, 2011 - 3:59 pm UTC

see http://docs.oracle.com/docs/cd/B32110_01/web.1013/b28236/toc.htm

(or any more current release than 10.1) for using the XDK for Soap services

ORACLE SOAP USING PL/SQL

sundar, January 03, 2011 - 6:35 pm UTC

TOM
I have found the useful link relating to this PL/SQL SOAP provider. see below 
http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11410
Which seems to be totally PL/SQL based, but I would like to conclude this session by putforthing the final question relalting to this dbms_epg, which is "how the performance will be during consumption of this type of SOAP service having millions of records in datanase. The consumption will be either from an another database PL/SQL type or from the application>
<code>I appreciate your feedback in this reagrd.
Thanks

Tom Kyte
January 04, 2011 - 7:07 am UTC

... "how the performance will be during consumption of this type of SOAP service
having millions of records in datanase. The consumption will be either from an
another database PL/SQL type or from the application ...


It depends on how efficient your code is - won't it.


If you "select * from a_million_billion_row_table where primary_key = :x", it'll be pretty darn fast.

If you "select count(some_non_indexed_Nullable_column) from a_million_billion_row_table" it'll be pretty amazingly slow.


Having millions or billions of records in a database is a meaningless metric when asking about performance. It doesn't tell the person you are asking anything.

SOAP using pl/sql

sundar dha, January 04, 2011 - 1:13 pm UTC

Tom
Thanks for your time.

Consume Web Service using PL/SQL code via an Application Server

Krishna Kant, August 14, 2013 - 7:07 am UTC

Hello Tom,

My requirement is very similar to the first question here, i.e, to consume a Web Service using PL/SQL code. I have a working application in 11g database that sends HTTP SOAP requests using the UTL_HTTP package as follows:

FUNCTION f_invoke(p_soap_msg VARCHAR2,
p_action VARCHAR2,
p_timeout VARCHAR2 DEFAULT 60)
RETURN CLOB
IS
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_soap_response VARCHAR2(32767);
l_response_clob CLOB;
BEGIN
UTL_HTTP.set_transfer_timeout(p_timeout);

l_http_request := UTL_HTTP.begin_request(p_url, 'POST', UTL_HTTP.http_version_1_1);

UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml; charset="utf-8"');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(p_soap_msg));
UTL_HTTP.set_header(l_http_request, 'SOAPAction', p_action);

UTL_HTTP.write_text(l_http_request, p_soap_msg);
l_http_response := UTL_HTTP.get_response(l_http_request);

DBMS_LOB.createtemporary(l_response_clob, TRUE, DBMS_LOB.call);
DBMS_LOB.open(l_response_clob, DBMS_LOB.lob_readwrite);

BEGIN
LOOP
UTL_HTTP.read_text(l_http_response, l_soap_response, 32767);
DBMS_LOB.writeappend(l_response_clob, LENGTH(l_soap_response), l_soap_response);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
UTL_HTTP.end_response(l_http_response);
END;

DBMS_LOB.close(l_response_clob);
DBMS_LOB.freetemporary(l_response_clob);

RETURN l_response_clob;
END f_invoke;

Now I need to implement this same solution in a way so that the HTTP call-out is not initiated directly by the database but routed via an Application Server (WebLogic in my case) so that my application conforms to the organization's architecture principles. Could you help me with this?

Thanks,
Krishna.