nmukhi 2002/12/09 13:47:04 Added: java/samples/ComplexSOAP/client/dynamic README.html Run.java Log: Client using WSIF DII for complex type sample Revision Changes Path 1.1 xml-axis-wsif/java/samples/ComplexSOAP/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 SimpleSOAP Sample using WSIF's dynamic invocation interface</h2> <p>You must have the following on your classpath: <ul> <li>wsif.jar</li> <li>wsifsamples.jar</li> <li>A JAXP compliant XML parser, such as Xerces</li> <li>wsdl4j.jar</li> <li>qname.jar</li> <li>axis.jar (since by default WSIF uses its Axis provider to invoke SOAP services)</li> <li>JAR files required by Axis - log4j.jar, commons-logging.jar, commons-discovery.jar, jaxrpc.jar, saaj.jar</li> </ul> </p> <p>After you have set up the CLASSPATH in your environment, to invoke this sample using WSIF's DII, run the <tt>Run</tt> class located in this directory. Specify as command line arguments the location of the WSDL file for the service and the zip code you are interested in. For example, <br><tt>java samples.ComplexSOAP.clients.dynamic.Run file:/mywsifinstallation/samples/ComplexSOAP/Zip2Geo.wsdl 10005</tt></p> <p>Look at the code in the <tt>Run.java</tt> file in this directory to see how to use WSIF's DII yourself. Note that the <tt>DynamicInvoker</tt> class we used to <a href="../../../SimpleSOAP/client/dynamic/README.html">invoke the SimpleSOAP sample dynamically</a> cannot be used for this one since the <tt>DynamicInvoker</tt> as it stands now is limited to invocation of services using primitive schema types only.</p> <hr width="100%"> </body></html> 1.1 xml-axis-wsif/java/samples/ComplexSOAP/client/dynamic/Run.java Index: Run.java =================================================================== package samples.ComplexSOAP.client.dynamic; import javax.xml.namespace.QName; import org.apache.wsif.WSIFService; import org.apache.wsif.WSIFMessage; import org.apache.wsif.WSIFPort; import org.apache.wsif.WSIFOperation; import org.apache.wsif.WSIFServiceFactory; import com.cdyne.ws.LatLongReturn; public class Run { public static void main(String [] args) throws Exception { // args[0] is the zip code if(args.length!=2) { System.out.println("Usage: java samples.ComplexSOAP.client.dynamic.Run <wsdl location> <zip code>"); System.exit(1); } // create a service factory WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); WSIFService service = factory.getService(args[0], null, null, "http://ws.cdyne.com", "Zip2GeoSoap"); // map types service.mapType(new QName("http://ws.cdyne.com","LatLongReturn"), Class.forName("com.cdyne.ws.LatLongReturn")); // get the port WSIFPort port = service.getPort(); // create the operation WSIFOperation operation = port.createOperation("GetLatLong"); // create the input, output and fault messages associated with this operation WSIFMessage input = operation.createInputMessage(); WSIFMessage output = operation.createOutputMessage(); WSIFMessage fault = operation.createFaultMessage(); // populate the input message input.setObjectPart("zipcode",args[1]); input.setObjectPart("LicenseKey",""); // do the invocation if (operation.executeRequestResponseOperation(input, output, fault)) { // invocation succeeded, extract information from output // message LatLongReturn zipInfo = (LatLongReturn) output.getObjectPart("GetLatLongResult"); System.out.println("This zip code is in "+zipInfo.getCity()+","+zipInfo.getStateAbbrev()+ " in "+zipInfo.getCounty()+" county\n"+ "It extends from longitude "+zipInfo.getFromLongitude()+" to longitude "+ zipInfo.getToLongitude()+"\n and from latitude "+zipInfo.getFromLatitude()+ " to latitude "+zipInfo.getToLatitude()); } else { System.out.println("Invocation failed"); // extract fault message info } } }