Source Code Cross Referenced for Run.java in  » Web-Services » wsif » localjava » client » stub » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » wsif » localjava.client.stub 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package localjava.client.stub;
002:
003:        import java.rmi.RemoteException;
004:
005:        import localjava.client.stub.addressbook.wsifservice.AddressBook;
006:        import localjava.client.stub.addressbook.wsiftypes.Address;
007:        import localjava.client.stub.addressbook.wsiftypes.Phone;
008:
009:        import org.apache.wsif.WSIFException;
010:        import org.apache.wsif.WSIFService;
011:        import org.apache.wsif.WSIFServiceFactory;
012:
013:        /**
014:         * Class that runs the localjava sample using a pregenerated stub interface
015:         * To use this class provide the location of the address book service's WSDL 
016:         * location on the command line. WSIF 
017:         * should then invoke the local java service for populating and then
018:         * querying an addressbook.
019:         * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
020:         */
021:
022:        public class Run {
023:            private static void addFirstAddress(AddressBook addressBook) {
024:                try {
025:
026:                    // create an address object to populate the input
027:                    Address address = new Address();
028:                    address.setStreetNum(25);
029:                    address.setStreetName("Willow Road");
030:                    address.setCity("MyTown");
031:                    address.setState("PA");
032:                    address.setZip(28382);
033:                    Phone phone = new Phone();
034:                    phone.setAreaCode(288);
035:                    phone.setExchange("555");
036:                    phone.setNumber("9891");
037:                    address.setPhoneNumber(phone);
038:
039:                    // do the invocation
040:                    System.out.println("Adding address for John Smith...");
041:                    addressBook.addEntry("John Smith", address);
042:
043:                } catch (WSIFException we) {
044:                    System.out.println("Got exception from WSIF, details:");
045:                    we.printStackTrace();
046:                } catch (RemoteException re) {
047:                    System.out
048:                            .println("Got exception while invoking stub, details:");
049:                    re.printStackTrace();
050:                }
051:            }
052:
053:            private static void addSecondAddress(AddressBook addressBook) {
054:                try {
055:
056:                    // create an address object to populate the input
057:                    Address address = new Address();
058:                    address.setStreetNum(20);
059:                    address.setStreetName("Peachtree Avenue");
060:                    address.setCity("Atlanta");
061:                    address.setState("GA");
062:                    address.setZip(39892);
063:                    Phone phone = new Phone();
064:                    phone.setAreaCode(701);
065:                    phone.setExchange("555");
066:                    phone.setNumber("8721");
067:                    address.setPhoneNumber(phone);
068:
069:                    // do the invocation
070:                    System.out.println("Adding address for Jane White...");
071:                    addressBook.addEntry("Jane", "White", address);
072:
073:                } catch (WSIFException we) {
074:                    System.out.println("Got exception from WSIF, details:");
075:                    we.printStackTrace();
076:                } catch (RemoteException re) {
077:                    System.out
078:                            .println("Got exception while invoking stub, details:");
079:                    re.printStackTrace();
080:                }
081:            }
082:
083:            private static void queryAddresses(AddressBook addressBook) {
084:                try {
085:
086:                    // do the invocation
087:                    System.out.println("Querying address for John Smith...");
088:                    Address address = addressBook
089:                            .getAddressFromName("John Smith");
090:
091:                    System.out
092:                            .println("Service returned the following address:");
093:                    System.out.println(address.getStreetNum() + " "
094:                            + address.getStreetName() + ", "
095:                            + address.getCity() + " " + address.getState()
096:                            + " " + address.getZip() + "; Phone: ("
097:                            + address.getPhoneNumber().getAreaCode() + ") "
098:                            + address.getPhoneNumber().getExchange() + "-"
099:                            + address.getPhoneNumber().getNumber());
100:
101:                    System.out.println("Querying address for Jane White...");
102:                    address = addressBook.getAddressFromName("Jane White");
103:
104:                    System.out
105:                            .println("Service returned the following address:");
106:                    System.out.println(address.getStreetNum() + " "
107:                            + address.getStreetName() + ", "
108:                            + address.getCity() + " " + address.getState()
109:                            + " " + address.getZip() + "; Phone: ("
110:                            + address.getPhoneNumber().getAreaCode() + ") "
111:                            + address.getPhoneNumber().getExchange() + "-"
112:                            + address.getPhoneNumber().getNumber());
113:
114:                } catch (WSIFException we) {
115:                    System.out.println("Got exception from WSIF, details:");
116:                    we.printStackTrace();
117:                } catch (RemoteException re) {
118:                    System.out
119:                            .println("Got exception while invoking stub, details:");
120:                    re.printStackTrace();
121:                }
122:            }
123:
124:            public static void main(String[] args) {
125:                try {
126:                    if (args.length != 1) {
127:                        System.out
128:                                .println("Usage: java localjava.client.stub.Run <wsdl location>");
129:                        System.exit(1);
130:                    }
131:
132:                    // create a service factory
133:                    WSIFServiceFactory factory = WSIFServiceFactory
134:                            .newInstance();
135:
136:                    // parse WSDL
137:                    WSIFService service = factory.getService(args[0], null,
138:                            null, "http://wsifservice.addressbook/",
139:                            "AddressBook");
140:
141:                    // create the stub
142:                    AddressBook stub = (AddressBook) service
143:                            .getStub(AddressBook.class);
144:
145:                    // do the invocations
146:                    addFirstAddress(stub);
147:                    addSecondAddress(stub);
148:                    queryAddresses(stub);
149:
150:                } catch (WSIFException we) {
151:                    System.out.println("Got exception from WSIF, details:");
152:                    we.printStackTrace();
153:                }
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.