Solved

Example of calling WCF webservice from Oracle PL SQL

Posted on 2011-09-22
3
2,581 Views
1 Endorsement
Last Modified: 2012-05-12
Hi,

I need to make a call to a .NET WCF webservice from PL/SQL in Oracle. The webservice will have a WSDL. Is there a tool I can use, or generic method available, to interrogate a WSDL and allow me to pass the required parameters to the web service method?

I don't have much experience in PL/SQL, so anything you can provide would be great! FYI, some of the examples on google, like the Tom Krueger example, don't seem to work. I have spent a lot of time googling this one, so would prefer a definitive answer, rather than a few links to check out.

Cheers,
Brett
1
Comment
Question by:designavenue
  • 2
3 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
Comment Utility
install utl_dbws  

and try this...

DECLARE
    service_          UTL_DBWS.service;
    call_             UTL_DBWS.call;
    service_qname     UTL_DBWS.qname;
    port_qname        UTL_DBWS.qname;
    operation_qname   UTL_DBWS.qname;
    string_type_qname UTL_DBWS.qname;
    l_namespace       VARCHAR2(1000);
    retx              SYS.XMLTYPE;
    xml_string        SYS.XMLTYPE;
    l_str             LONG;
BEGIN
    DBMS_JAVA.set_output(100000);
    l_namespace := 'http://xmlme.com/WebServices';
    service_qname := UTL_DBWS.to_qname(l_namespace, 'Shakespeare');
    service_ :=
        UTL_DBWS.create_service(
            httpuritype('http://www.xmlme.com/WSShakespeare.asmx?WSDL'),
            service_qname
        );
    port_qname := UTL_DBWS.to_qname(l_namespace, 'ShakespeareSoap');
    operation_qname := UTL_DBWS.to_qname(l_namespace, 'GetSpeech');
    call_ := UTL_DBWS.create_call(service_, port_qname, operation_qname);
    UTL_DBWS.set_property(call_, 'SOAPACTION_USE', 'TRUE');
    UTL_DBWS.set_property(call_, 'SOAPACTION_URI', 'http://xmlme.com/WebServices/GetSpeech');
    UTL_DBWS.set_property(call_, 'ENCODINGSTYLE_URI', 'http://schemas.xmlsoap.org/soap/encoding/');
    UTL_DBWS.set_property(call_, 'OPERATION_STYLE', 'document');
    string_type_qname := UTL_DBWS.to_qname('http://www.w3.org/2001/XMLSchema', 'string');
    UTL_DBWS.ADD_PARAMETER(
        call_,
        'Request',
        string_type_qname,
        'ParameterMode.IN'
    );
    UTL_DBWS.set_return_type(call_, string_type_qname);

    xml_string :=
        xmltype(
'<?xml version="1.0" encoding="utf-8"?>
 <GetSpeech xmlns="http://xmlme.com/WebServices">
   <Request>To be, or not to be</Request>
 </GetSpeech>'
        );
    retx := UTL_DBWS.invoke(call_handle => call_, request => xml_string);

    l_str := retx.EXTRACT('/*').getstringval();

    LOOP
        EXIT WHEN l_str IS NULL;
        DBMS_OUTPUT.put_line(SUBSTR(l_str, 1, INSTR(l_str, CHR(10)) - 1));
        l_str := SUBSTR(l_str, INSTR(l_str, CHR(10)) + 1);
    END LOOP;

    UTL_DBWS.release_service(service_);
END;
/

Open in new window

0
 

Author Closing Comment

by:designavenue
Comment Utility
Solutin wasn't generic enough
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
you could have asked for help
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to take different types of Oracle backups using RMAN.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now