<%-- Copyright (c) 2000 by BEA Systems, Inc. All Rights Reserved. --%> <html> <head> <title>BizClient</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <h2>BizTalk Client</h2> <hr> <% if(request.getParameter("submit") == null || request.getParameter("submit").equals("")) { %> Fill out the form below to submit a stock trade. When you submit the form, this JSP page will generate a BizTalk document based on your input and send it to the address specified below. The BizTalk Server will accept the form and hand it off to appropriate EJBean(s) for processing. <form method="POST" action="BizClient.jsp"> <table cellpadding="3"> <tr valign="top"><td> </td> <td>Customer name: </td> <td><input type="text" name="customer" size="30"></td> </tr> <tr valign="top"><td> </td> <td>Stock symbol: </td> <td><select name="symbol"> <option value="BEAS" selected>BEAS</option> <option value="INTL">INTL</option> </select></td> </tr> <tr valign="top"><td> </td> <td>Action: </td> <td><select name="action"> <option value="buy" selected>Buy</option> <option value="sell">Sell</option> </select></td> </tr> <tr valign="top"><td> </td> <td>Number of shares: </td> <td><input type="text" name="shares" size="30"></td> </tr> <tr valign="top"><td> </td> <td>BizTalk Server address: </td> <td><input type="text" name="address" size="30"> <br>The address must be identicle to the uri defined in the BizTalk server conifuration file.</td> </tr> <tr valign="top"><td> </td> <td> <p><input type="submit" name="submit" value="Submit trade"></td><td></td> </tr> </table> <% } else { %> <%@ page import="java.util.*" %> <%@ page import="java.net.*" %> <%@ page import="java.io.*" %> <%@ page import="examples.xml.biztalk.*" %> <% try { URL url = new URL(request.getParameter("address")); URLConnection urlc = url.openConnection(); urlc.setDoOutput(true); urlc.setDoInput(true); PrintWriter pw = new PrintWriter(new OutputStreamWriter(urlc.getOutputStream()), true); // This implementation does not make use of many of the available // fields in a BizTalk document. Critical fields for this implementation // include type, fromAddress, toAddress, and body. DOMOutgoingMessage om = new DOMOutgoingMessage(); om.setType("Trade"); om.setNameSpace(); om.setFromAddress(request.getParameter("customer")); om.setToAddress(request.getParameter("address")); om.setBodyAsXML("<Trade customer='"+request.getParameter("customer") + "' action='"+request.getParameter("action") + "' symbol='"+request.getParameter("symbol") + "' shares='"+request.getParameter("shares")+"'/>"); pw.println(om.toString()); urlc.getInputStream(); } catch (Exception e) { e.printStackTrace(); } %> Thank you! Your trade has been recieved. A BizTalk document has been sent to <b><%=request.getParameter("address")%></b> with the following information: <p> <table cellpadding="3"> <tr valign="top"><td> </td> <td>Customer name: </td> <td><%=request.getParameter("customer")%></td> </tr> <tr valign="top"><td> </td> <td>Stock symbol: </td> <td><%=request.getParameter("symbol")%></td> </tr> <tr valign="top"><td> </td> <td>Action: </td> <td><%=request.getParameter("action")%></td> </tr> <tr valign="top"><td> </td> <td>Number of shares: </td> <td><%=request.getParameter("shares")%></td> </tr> </table> <p> <a href="BizClient.jsp">Enter another trade</a> <% } %> </body> </html>