home *** CD-ROM | disk | FTP | other *** search
Java Source | 2003-02-24 | 2.3 KB | 89 lines |
- /**
- * %wsgw_sample_start%
- * Licensed Materials - Property of IBM
- *
- * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.
- *
- * US Government Users Restricted Rights - Use, duplication or
- * disclosure restricted by GSA ADP Schedule Contract with
- * IBM Corp.
- * %wsgw_sample_end%
- */
-
- package services.calendar;
-
- import java.io.*;
- import java.net.*;
- import java.util.*;
- import org.apache.soap.*;
- import org.apache.soap.rpc.*;
- import org.apache.soap.transport.*;
- import org.apache.soap.transport.http.*;
-
- /**
- * See README for info.
- *
- * @author William A. Nagy (nagy@watson.ibm.com)
- */
- public class GetDayOfTheWeek
- {
- public static void main (String[] args)
- throws Exception
- {
- if ((args.length != 6) && (args.length != 8))
- {
- System.err.println ("Usage: java " + GetDayOfTheWeek.class.getName () +
- " SOAP-router-URL method-namespace-uri" +
- " action-uri month date year [username password]");
- System.exit (1);
- }
-
- URL url = new URL(args[0]);
- String id = args[1];
- String actionURI = args[2];
- Integer month = new Integer(args[3]);
- Integer date = new Integer(args[4]);
- Integer year = new Integer(args[5]);
- String userName = null;
- String password = null;
- if (args.length == 8)
- {
- userName = args[6];
- password = args[7];
- }
-
- /*Build the call.*/
- Call call = new Call();
- call.setTargetObjectURI(id);
- call.setMethodName("dayOfTheWeekOp");
- call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
- Vector params = new Vector();
- params.addElement(new Parameter("month", int.class, month, null));
- params.addElement(new Parameter("date", int.class, date, null));
- params.addElement(new Parameter("year", int.class, year, null));
- call.setParams(params);
-
- if (userName != null)
- {
- SOAPHTTPConnection shc = new SOAPHTTPConnection();
- shc.setUserName(userName);
- shc.setPassword(password);
- call.setSOAPTransport(shc);
- }
-
- Response resp = call.invoke(url, actionURI);
-
- // Check the response.
- if (resp.generatedFault())
- {
- Fault fault = resp.getFault();
- System.out.println ("Ouch, the call failed: " + fault);
- }
- else
- {
- Parameter result = resp.getReturnValue();
- System.out.println(result.getValue());
- }
- }
- }
-