nmukhi 2002/12/17 09:14:12
Modified: java/samples/multibinding README.html
Added: java/samples/multibinding StockQuoteService.wsdl
java/samples/multibinding/client/dynamic README.html
java/samples/multibinding/client/stub README.html
java/samples/multibinding/client/stub/com/themindelectric/www
NetXmethodsServicesStockquoteStockQuotePortType.java
java/samples/multibinding/service README.html
StockQuoteService.java
Log:
Completed multibinding sample
Revision Changes Path
1.2 +21 -0 xml-axis-wsif/java/samples/multibinding/README.html
Index: README.html
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/samples/multibinding/README.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- README.html 11 Dec 2002 16:00:48 -0000 1.1
+++ README.html 17 Dec 2002 17:14:12 -0000 1.2
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="Author" content="Nirmal Mukhi">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<title>Web Services Invocation Framework: Samples</title>
+<link rel="stylesheet" href="wsif.css" type="text/css"></head>
+
+<body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2"
marginwidth="2" marginheight="2">
+
+<h1>
+Web Services Invocation Framework:<br>
+Multiple binding sample</h1>
+<p>This sample aims to demonstrate the invocation of a service that offers multiple
bindings. We use the familiar stock quote service, and expose the functionality via a
SOAP binding (implemented by the remotely hosted service on XMethods, as in the <a
href="../simplesoap/README.html">simplesoap sample</a>) and also via a local java
class binding. WSIF allows the client to defer selection of the actual port used for
invocation until runtime. To demonstrate this, both the clients in this sample allow
specification of a preferred port at runtime. If you choose the port that uses the
java binding, the local class is called. If you choose the SOAP port, the SOAP service
is called. The high level view of the service remains uniform.
+
+<p>The <a href="StockQuoteService.wsdl">WSDL file</a> is in this sample
directory.</p>
+<p>The SOAP implementation is hosted by the good folks at <a
href="http://www.xmethods.net">XMethods</a>. The service URL, where you can find
details on the service implementation, etc. is <a
href="http://www.xmethods.net/ve2/ViewListing.po?serviceid=2">here</a>.</p>
+<p><a href="service/README.html">Here's</a> how the local java class that
implements the service functionality is implemented.</p>
+<p><a href="client/dynamic/README.html">Here's</a> how to invoke this service
dynamically using WSIF's dynamic invocation interface (DII).</p>
+<p><a href="client/stub/README.html">Here's</a> how to invoke this service by first
generating the stub interface and using this directly through WSIF's dynamic proxy,
thus hiding all WSIF specifics from the client code. Note that the stub interface used
is the the service interface as defined by the JAX-RPC specification.</p>
+<hr width="100%">
+</body></html>
1.1 xml-axis-wsif/java/samples/multibinding/StockQuoteService.wsdl
Index: StockQuoteService.wsdl
===================================================================
<?xml version='1.0' encoding='UTF-8'?>
<definitions name='net.xmethods.services.stockquote.StockQuote'
targetNamespace='http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/'
xmlns:tns='http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/'
xmlns:electric='http://www.themindelectric.com/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
xmlns:java="http://schemas.xmlsoap.org/wsdl/java/"
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getQuoteResponse1'>
<part name='Result' type='xsd:float'/>
</message>
<message name='getQuoteRequest1'>
<part name='symbol' type='xsd:string'/>
</message>
<portType name='net.xmethods.services.stockquote.StockQuotePortType'>
<operation name='getQuote' parameterOrder='symbol'>
<input message='tns:getQuoteRequest1'/>
<output message='tns:getQuoteResponse1'/>
</operation>
</portType>
<!-- SOAP binding -->
<binding name='StockQuoteSOAPBinding'
type='tns:net.xmethods.services.stockquote.StockQuotePortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getQuote'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/>
<input>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<!-- Java binding -->
<binding name='StockQuoteJavaBinding'
type='tns:net.xmethods.services.stockquote.StockQuotePortType'>
<java:binding/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
<format:typeMap typeName="xsd:float" formatType="java.lang.Float" />
</format:typeMapping>
<operation name="getQuote">
<java:operation
methodName="getQuote"
methodType="instance" />
<input/>
</operation>
</binding>
<service name='net.xmethods.services.stockquote.StockQuoteService'>
<documentation>net.xmethods.services.stockquote.StockQuote web
service</documentation>
<port name='StockQuoteSOAPPort'
binding='tns:StockQuoteSOAPBinding'>
<soap:address location='http://66.28.98.121:9090/soap'/>
</port>
<port name="StockQuoteJavaPort" binding="tns:StockQuoteJavaBinding">
<java:address className="multibinding.service.StockQuoteService"/>
</port>
</service>
</definitions>
1.1
xml-axis-wsif/java/samples/multibinding/client/dynamic/README.html
Index: README.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Nirmal Mukhi">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Web Services Invocation Framework: Samples</title>
<link rel="stylesheet" href="wsif.css" type="text/css"></head>
<body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2"
marginheight="2">
<h2>
Web Services Invocation Framework:<br>
Invoking the MultiBinding Sample using WSIF's dynamic invocation interface</h2>
<p>After you have <a href="../../../../doc/samples.html">set up the CLASSPATH in
your environment</a>, to invoke this sample using WSIF's DII, run the DynamicInvoker
class. Specify as command line arguments the location of the WSDL file for the
multibinding sample followed by the operation you wish to invoke, an optional
preferred port in parentheses and the symbol for the company whose stockquote you are
interested in. For example,
<br>Invocation with no port preference: <tt>java clients.DynamicInvoker
samples/simplesoap/StockquoteSOAP.wsdl getQuote IBM</tt>
<br>Invocation with SOAP port preference: <tt>java clients.DynamicInvoker
samples/simplesoap/StockquoteSOAP.wsdl getQuote(StockQuoteSOAPPort) IBM</tt>
<br>Invocation with java port preference: <tt>java clients.DynamicInvoker
samples/simplesoap/StockquoteSOAP.wsdl getQuote(StockQuoteJavaPort) IBM</tt>
</p>
<p>To see details of how the WSIF API is used to make invocations dynamically, take
a look at the code for the <a
href="../../../clients/DynamicInvoker.java">DynamicInvoker class</a>. Note the use of
the <tt>portName</tt> parameter to make the invocation using the selected port.</p>
<hr width="100%">
</body></html>
1.1 xml-axis-wsif/java/samples/multibinding/client/stub/README.html
Index: README.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Nirmal Mukhi">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Web Services Invocation Framework: Samples</title>
<link rel="stylesheet" href="wsif.css" type="text/css"></head>
<body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2"
marginheight="2">
<h2>
Web Services Invocation Framework:<br>
Invoking the Multibinding Sample through a high level stub interface</h2>
First, you must <a href="../../../../doc/samples.html">set up the CLASSPATH in your
environment</a>.
<p>This directory contains a file called <tt>Run.java</tt> that contains the
<tt>main</tt> method. This is the logic that uses the generated stub interface to run
the sample. So you can run this class, specifying on the command line the location of
the WSDL file for the sample, the symbol for the company whose stock quote you are
interested in and an optional port preference. For example,
<br>Invoking the service without specifying any port preference:
<tt>java multibinding.client.stub.Run samples/multibinding/StockquoteSOAP.wsdl
IBM</tt>
<br>Invoking the service with the SOAP port preference:
<tt>java multibinding.client.stub.Run samples/multibinding/StockquoteSOAP.wsdl IBM
StockQuoteSOAPPort</tt>
<br>Invoking the service with the java port preference:
<tt>java multibinding.client.stub.Run samples/multibinding/StockquoteSOAP.wsdl IBM
StockQuoteJavaPort</tt>
</p>
<p>The WSIF API allows programs to choose a preferred port when getting a reference
to the stub interface. Any calls made via that stub interface will then use the
selected port and its associated binding protocol. See the <tt>Run.java</tt> code for
details.</p>
<p>To generate the stub interface, you can use any tool that generates Java
interfaces for WSDL services using their port type descriptions, such as WSDL2Java
from Axis. WSIF assumes a correspondence between the generated Java interface and the
WSDL port type that has its abstract description as specified in the JAX-RPC
specification. This particular sample used WSDL2Java in the following way:<br>
<tt>java org.apache.axis.wsdl.WSDL2Java ../../StockquoteService.wsdl</tt><br>
After the tool finished running, we deleted all the generated files except
<tt>NetXmethodsServicesStockquoteStockQuotePortType.java</tt> (this is the java
interface corresponding to the port type and is all that is required by WSIF).</p>
<hr width="100%">
</body></html>
1.1
xml-axis-wsif/java/samples/multibinding/client/stub/com/themindelectric/www/NetXmethodsServicesStockquoteStockQuotePortType.java
Index: NetXmethodsServicesStockquoteStockQuotePortType.java
===================================================================
/**
* NetXmethodsServicesStockquoteStockQuotePortType.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package multibinding.client.stub.com.themindelectric.www;
public interface NetXmethodsServicesStockquoteStockQuotePortType extends
java.rmi.Remote {
public float getQuote(java.lang.String symbol) throws java.rmi.RemoteException;
}
1.1 xml-axis-wsif/java/samples/multibinding/service/README.html
Index: README.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Nirmal Mukhi">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Web Services Invocation Framework: Samples</title>
<link rel="stylesheet" href="wsif.css" type="text/css"></head>
<body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2"
marginheight="2">
<h2>
Web Services Invocation Framework:<br>
Java implementation of the StockQuoteService</h2>
Take a look at the <tt><a
href="StockQuoteService.java">StockQuoteService.java</a></tt> file in this directory.
<p>This class implements the stock quote service functionality advertised in <a
href="../StockQuoteService.wsdl">the sample WSDL</a>. This implementation actually
uses HTTP GET to communicate with a remote web site that returns the quote for a given
stock symbol; of course it could also look up a local table of stock quotes; the
details are completely hidden from the code that accesses the class. Note that the
WSDL file refers to this class as the service endpoint in the <tt>java:address</tt>
element.</p>
<hr width="100%">
</body></html>
1.1
xml-axis-wsif/java/samples/multibinding/service/StockQuoteService.java
Index: StockQuoteService.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "AXIS" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package multibinding.service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.net.URL;
/**
*
* @author Sanjiva Weerawarana ([EMAIL PROTECTED])
* @author Doug Davis ([EMAIL PROTECTED])
*/
public class StockQuoteService {
public float getQuote (String symbol) throws Exception {
// get a real (delayed by 20min) stockquote from
// http://www.xmltoday.com/examples/stockquote/. The IP addr
// below came from the host that the above form posts to ..
if ( symbol.equals("XXX") ) return( (float) 55.25 );
URL url = new URL( "http://services.xmethods.net/" +
"axis/getQuote?s="+symbol );
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse( url.toExternalForm() );
Element elem = doc.getDocumentElement();
NodeList list = elem.getElementsByTagName( "stock_quote" );
if ( list != null && list.getLength() != 0 ) {
elem = (Element) list.item(0);
list = elem.getElementsByTagName( "price" );
elem = (Element) list.item(0);
String quoteStr = elem.getAttribute("value");
try {
return Float.valueOf(quoteStr).floatValue();
} catch (NumberFormatException e1) {
// maybe its an int?
try {
return Integer.valueOf(quoteStr).intValue() * 1.0F;
} catch (NumberFormatException e2) {
return -1.0F;
}
}
}
return( 0 );
}
}