|
Techniques for Robust, Database-driven Web Services by Steve Muench
WSJ Vol 03 Issue 1 - pg.50
Listing 1
/* Body (Private Implementation) for Forum Info Package */
PACKAGE BODY forum_info IS
FUNCTION Forum_Thread_Summary_Info( the_forum_id NUMBER,
the_thread_id NUMBER)
RETURN Forum_Thread IS
retval Forum_Thread;
BEGIN
/* Select & Construct Forum_Thread object based on scalar info */
/* o.name is null in outer join if last post is non Oracle */
SELECT Forum_Thread(f.forum_id,f.thread_id,f.title,f.author,
f.last_post,DECODE(o.name,NULL,'Y','N'),
f.last_post_author,f.replies)
INTO retval
FROM forum_threads f, oracle_team o
WHERE f.forum_id = the_forum_id
AND f.thread_id = the_thread_id
AND f.last_post_author = o.name (+);
RETURN retval;
END;
END;
Listing 2
<!-- WSDL fragment defining the ForumThread schema type -->
<types>
<schema
targetNamespace="http://tempuri.org/IForum_info.xsd"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="ForumThread">
<all>
<element name="threadId" type="decimal"/>
<element name="forumId" type="decimal"/>
<element name="title" type="string"/>
<element name="author" type="string"/>
<element name="lastReply" type="dateTime"/>
<element name="awaitingOracleReply" type="string"/>
<element name="LastReplyFrom" type="string"/>
<element name="totalReplies" type="decimal"/>
</all>
</complexType>
</schema>
</types>
Listing 3
using System;
using Test.otnserver;
namespace Test {
class MyTest {
static void Main(string[] args) {
// Instantiate the web service stub
ForumInfo info = new ForumInfo();
// Retrieve the forum thread structure from the web service
ForumThread ft = info.forum_thread_summary_info(315684,1431409);
Console.WriteLine(
"Title: "+ft.title+"\n"+
"Author: "+ft.author +"\n"+
"Waiting on Oracle?: "+ft.awaitingOracleReply);
}
}
}
|