<%@ include file="../demoUtil.jsp" %>

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
OracleJSP Web Service Demo
</TITLE>
</HEAD>
<BODY>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 >
<tr>
<td WIDTH="10" BGCOLOR="#FF0000">&nbsp;</td>
<td BGCOLOR="#FF0000">
<b><font face="Arial, Helvetica"><font color="#FFFFFF"><font size=+1>OracleJSP Dynamic Invocation of Web Service Demo</font></font></font></b></td>
<td WIDTH="10" BGCOLOR="#FF1010">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF2020">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF3030">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF4040">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF6060">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF7070">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF8080">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FF9090">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFA0A0">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFB0B0">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFC0C0">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFD0D0">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFE0E0">&nbsp;</td>
<td WIDTH="10" BGCOLOR="#FFF0F0">&nbsp;</td>
</tr>
</table>
<%
String hwynum = request.getParameter("hwyNum");

if(hwynum == null)
{
%>
<P>
<B>Description:</B>
<BR>
This example demonstrates use of JSP to develop a Web Service client for a web 
service provided by a third party provider.
<BR>
This demo uses  web services provided by <A HREF="http://www.xmethods.org">XMethods</A>.
<BR>
<BR>
<BR>
The JSP page invokes a JavaBean which uses Oracle's Dynamic Invocation API for Web services . 
<BR>
<hr WIDTH="100%">
<form method=POST action=dynamicws.jsp>
<BR>
The JSP page dynamically invoke two differant web services.
<BR>
<B>1 : California Traffic Information :</B>
<BR>
This Information system provides current information regarding the condition of 
the California State Highway System. The information provided covers incidents 
that cause significant delays to the normal flow of traffic such as, but not 
limited to, full closures, 1-way traffic controls, lane closures, construction, 
maintenance projects, and emergencies. Normal commute traffic, ramp closures and
traffic flow conditions are not included in these reports. 
The information in each report is the latest information reported to the Highway Information Center.
<BR>
<BR>
Examples of CA highway numbers are I-80, I-5, US-101, SR-84, I-680, US-50, SR-92 etc..
</P>
The description WSDL of this web service is available at 
<A HREF="http://www.xmethods.net/sd/2001/CATrafficService.wsdl">http://www.xmethods.net/sd/2001/CATrafficService.wsdl</A>
<BR>
<table WIDTH="100%" >
<tr>
<td>
<B>Enter California Highway number(s) ? </B></td>
<td><input type=text name=hwyNum></td>
</tr>
<tr>
<td COLSPAN="2">Separate multiple route numbers with commas.</td>
</tr>
<tr>
<td COLSPAN="2"></td>
</tr>
<tr>
<td  COLSPAN="2"><B>2 : 20 minutes delayed Stock quote :</B>
<BR>
This web service provides delayed stock quotes from NYSE and NASDAQ.
<BR>
The description WSDL of this web service is available at 
<A HREF="http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl">http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl</A>
<BR></td>
</tr>
<tr>
	<td><B>Enter a Stock symbol ? </B></td>
	<td><input type=text name=stockSymbol></td>
</tr>
<tr>
	<td COLSPAN="4"><CENTER><input type=submit value="Submit"></CENTER></td>
</tr>
</table>
<BR>
</form>
<%}
else
{
%>

<P>
<B>Current Time :</B><% out.println((new java.util.Date()).toString()); %>
</P>

<jsp:usebean id='traffic' scope='page' class='oracle.j2ee.ws.client.impl.WSClientBean' />
<jsp:setProperty name="traffic" property="*" />
<jsp:setProperty name="traffic" property="WsdlUrl" value="http://www.xmethods.net/sd/2001/CATrafficService.wsdl"/>

<%
	
  String[] inMsgPartNames = new String[1];
  inMsgPartNames[0] = "hwynums";  // Input Part name 
  Object[] inMsgPartValues = new Object[1];
  inMsgPartValues[0] = new String(hwynum); 


%>
<hr WIDTH="100%">
<h2>Traffic Web Service :</h2>
<B>Latest traffic condition on CA highway <%=util.HTMLReplace(hwynum)%> is as follows :</B>
<BR>
<P>
<%=traffic.formatText((String) traffic.invokeOperation("getTraffic",
                                                       inMsgPartNames,
                                                       inMsgPartValues)) %>
</P>
<jsp:usebean id='stock' scope='page' class='oracle.j2ee.ws.client.impl.WSClientBean' />
<jsp:setProperty name="stock" property="*" />
<jsp:setProperty name="stock" property="WsdlUrl" value="http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"/>

<%
 
  String stockSymbol = request.getParameter("stockSymbol");
  
  String[] inMsgPartNames2 = new String[1];
  inMsgPartNames2[0] = "symbol";  // Input Part name 
  Object[] inMsgPartValues2 = new Object[1];
  inMsgPartValues2[0] = new String(stockSymbol); 
 
%>
<BR>
<BR>
<hr WIDTH="100%">
<h2>Stock Web Service :</h2>
<B>Last trade price of  <%=util.HTMLReplace(stockSymbol)%> stock is (20 min delayed):  
<%=stock.invokeOperation("getQuote",
                         inMsgPartNames2,
                         inMsgPartValues2)%></B>

<BR>
<BR>
<BR>
<BR>
<hr WIDTH="100%">
Web Service owner and provider is  <A HREF="http://www.xmethods.org">XMethods</A>
<BR>
Source of the this information is Caltrans website (California Department of Transportation).
<BR>
<%}%>
<BR>
<p><b><font face="Arial, Helvetica"><font color="#FF5050"><font size=-1>Copyright
(c) 2001, 2002, Oracle Corporation. All rights reserved.</font></font></font></b>
</BODY>
</HTML>
