Home » Developer & Programmer » JDeveloper, Java & XML » XMLTypes as in, out from JSP page (Jdeveloper 10.1.3.3 oracle 10.2)
XMLTypes as in, out from JSP page [message #319278] Fri, 09 May 2008 10:02
jjjjennings
Messages: 1
Registered: May 2008
Junior Member
I am fairly new to programming with XML types and Java. I have been trying to write an Ajax servlet (Jdeveloper 10.1.3.3) that calls a function in an oracle package (10.2) that takes in an XMLtype and returns an XMLtype. I seem to be only able to get this to work when I change the function and pass in a varchar2 and return a clob. Any help would be appreciated on how to pass and return XMLtypes.
Here is a snippet of what I can get to work with varchar2 and clob:
Java:
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");

Context ctx = new InitialContext();
DataSource ds=(DataSource)ctx.lookup("jdbc/OESDS");
Connection conn = ds.getConnection(userName, password);

Statement stmt = conn.createStatement();
CallableStatement cs = null;
cs = conn.prepareCall("{? = call OM.BUSINESSRULESVALIDATION_PKG.BusinessRulesCoordinator(?)}");
cs.registerOutParameter(1, Types.CLOB);
String xmlString = "<Request><ConsumerRequestType>MCValidateItem</ConsumerRequestType><ItemCode>" + itemNumber + "</ItemCode></Request>";

cs.setString(2, xmlString);

cs.execute();

String result = cs.getString(1);

Oracle function
function BusinessRulesCoordinator(BusinessRuleXML1 varchar2) return clob is
outXML xmltype;
bOut number;
fxToCall VARCHAR2(200);
failureMSG VARCHAR(200);
BusinessRuleXML xmltype;

CURSOR reqInputscur(inCONSUMERREQUESTTYPE IN VARCHAR2, incallingsequence IN NUMBER) IS
SELECT requiredinputfieldname
from businessrulestoconsumer_view
WHERE consumerrequesttype = inCONSUMERREQUESTTYPE
and callingsequence = incallingsequence;
reqInputRec reqInputscur%ROWTYPE;

begin
BusinessRuleXML := xmltype(BusinessRuleXML1);
-- and on the return back
return(TO_CLOB(outXML.getStringVal));
Previous Topic: Converting XMLTYPE data to CLOB and getClobVal() (merged 3)
Next Topic: JDeveloper SelectOneChoice
Goto Forum:
  


Current Time: Tue Dec 17 23:42:26 CST 2024