Source Code Cross Referenced for Run.java in  » Web-Services » wsif » localjava » client » dynamic » 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.dynamic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package localjava.client.dynamic;
002:
003:        import javax.xml.namespace.QName;
004:
005:        import org.apache.wsif.WSIFMessage;
006:        import org.apache.wsif.WSIFException;
007:        import org.apache.wsif.WSIFOperation;
008:        import org.apache.wsif.WSIFPort;
009:        import org.apache.wsif.WSIFService;
010:        import org.apache.wsif.WSIFServiceFactory;
011:
012:        import localjava.client.stub.addressbook.wsiftypes.Address;
013:        import localjava.client.stub.addressbook.wsiftypes.Phone;
014:
015:        public class Run {
016:
017:            private static void addFirstAddress(WSIFPort port) {
018:                try {
019:                    // create the operation
020:                    // note that we have two operations with the same name, 
021:                    // so we need to specify the name of the input and output 
022:                    // messages as well
023:                    WSIFOperation operation = port.createOperation("addEntry",
024:                            "AddEntryWholeNameRequest", null);
025:
026:                    // create the input message associated with this operation
027:                    WSIFMessage input = operation.createInputMessage();
028:
029:                    // populate the input message
030:                    input.setObjectPart("name", "John Smith");
031:
032:                    // create an address object to populate the input
033:                    Address address = new Address();
034:                    address.setStreetNum(25);
035:                    address.setStreetName("Willow Road");
036:                    address.setCity("MyTown");
037:                    address.setState("PA");
038:                    address.setZip(28382);
039:                    Phone phone = new Phone();
040:                    phone.setAreaCode(288);
041:                    phone.setExchange("555");
042:                    phone.setNumber("9891");
043:                    address.setPhoneNumber(phone);
044:
045:                    input.setObjectPart("address", address);
046:
047:                    // do the invocation
048:                    System.out.println("Adding address for John Smith...");
049:                    operation.executeInputOnlyOperation(input);
050:
051:                } catch (WSIFException we) {
052:                    System.out.println("Got exception from WSIF, details:");
053:                    we.printStackTrace();
054:                }
055:            }
056:
057:            private static void addSecondAddress(WSIFPort port) {
058:                try {
059:
060:                    // create the operation
061:                    // note that we have two operations with the same name, so we need to specify the
062:                    // name of the input and output messages as well
063:                    WSIFOperation operation = port.createOperation("addEntry",
064:                            "AddEntryFirstAndLastNamesRequest", null);
065:
066:                    // create the input message associated with this operation
067:                    WSIFMessage input = operation.createInputMessage();
068:
069:                    // populate the input message
070:                    input.setObjectPart("firstName", "Jane");
071:                    input.setObjectPart("lastName", "White");
072:
073:                    // create an address object to populate the input
074:                    Address address = new Address();
075:                    address.setStreetNum(20);
076:                    address.setStreetName("Peachtree Avenue");
077:                    address.setCity("Atlanta");
078:                    address.setState("GA");
079:                    address.setZip(39892);
080:                    Phone phone = new Phone();
081:                    phone.setAreaCode(701);
082:                    phone.setExchange("555");
083:                    phone.setNumber("8721");
084:                    address.setPhoneNumber(phone);
085:
086:                    input.setObjectPart("address", address);
087:
088:                    // do the invocation
089:                    System.out.println("Adding address for Jane White...");
090:                    operation.executeInputOnlyOperation(input);
091:
092:                } catch (WSIFException we) {
093:                    System.out.println("Got exception from WSIF, details:");
094:                    we.printStackTrace();
095:                }
096:            }
097:
098:            private static void queryAddresses(WSIFPort port) {
099:                try {
100:                    // create the operation
101:                    WSIFOperation operation = port
102:                            .createOperation("getAddressFromName");
103:
104:                    // create the input message associated with this operation
105:                    WSIFMessage input = operation.createInputMessage();
106:                    WSIFMessage output = operation.createOutputMessage();
107:                    WSIFMessage fault = operation.createFaultMessage();
108:
109:                    // populate the input message
110:                    input.setObjectPart("name", "John Smith");
111:
112:                    // do the invocation
113:                    System.out.println("Querying address for John Smith...");
114:                    if (operation.executeRequestResponseOperation(input,
115:                            output, fault)) {
116:                        // invocation succeeded
117:                        // extract the address from the output message
118:                        Address address = (Address) output
119:                                .getObjectPart("address");
120:                        System.out
121:                                .println("Service returned the following address:");
122:                        System.out.println(address.getStreetNum() + " "
123:                                + address.getStreetName() + ", "
124:                                + address.getCity() + " " + address.getState()
125:                                + " " + address.getZip() + "; Phone: ("
126:                                + address.getPhoneNumber().getAreaCode() + ") "
127:                                + address.getPhoneNumber().getExchange() + "-"
128:                                + address.getPhoneNumber().getNumber());
129:                    } else {
130:                        // invocation failed, check fault message
131:                    }
132:
133:                    // create the operation
134:                    operation = port.createOperation("getAddressFromName");
135:
136:                    // create the input message associated with this operation
137:                    input = operation.createInputMessage();
138:                    output = operation.createOutputMessage();
139:                    fault = operation.createFaultMessage();
140:
141:                    // populate the input message
142:                    input.setObjectPart("name", "Jane White");
143:
144:                    // do the invocation
145:                    System.out.println("Querying address for Jane White...");
146:                    if (operation.executeRequestResponseOperation(input,
147:                            output, fault)) {
148:                        // invocation succeeded
149:                        // extract the address from the output message
150:                        Address address = (Address) output
151:                                .getObjectPart("address");
152:                        System.out
153:                                .println("Service returned the following address:");
154:                        System.out.println(address.getStreetNum() + " "
155:                                + address.getStreetName() + ", "
156:                                + address.getCity() + " " + address.getState()
157:                                + " " + address.getZip() + "; Phone: ("
158:                                + address.getPhoneNumber().getAreaCode() + ") "
159:                                + address.getPhoneNumber().getExchange() + "-"
160:                                + address.getPhoneNumber().getNumber());
161:                    } else {
162:                        // invocation failed, check fault message
163:                    }
164:                } catch (WSIFException we) {
165:                    System.out.println("Got exception from WSIF, details:");
166:                    we.printStackTrace();
167:                }
168:            }
169:
170:            public static void main(String[] args) throws Exception {
171:                if (args.length != 1) {
172:                    System.out
173:                            .println("Usage: java samples.java.client.dynamic.Run <wsdl location>");
174:                    System.exit(1);
175:                }
176:
177:                // create a service factory
178:                WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
179:                WSIFService service = factory.getService(args[0], null, null,
180:                        "http://wsifservice.addressbook/", "AddressBook");
181:
182:                // map types
183:                service
184:                        .mapType(
185:                                new QName("http://wsiftypes.addressbook/",
186:                                        "Address"),
187:                                Class
188:                                        .forName("localjava.client.stub.addressbook.wsiftypes.Address"));
189:                service
190:                        .mapType(
191:                                new QName("http://wsiftypes.addressbook/",
192:                                        "Phone"),
193:                                Class
194:                                        .forName("localjava.client.stub.addressbook.wsiftypes.Phone"));
195:
196:                // get the port
197:                WSIFPort port = service.getPort();
198:
199:                // add the first address
200:                addFirstAddress(port);
201:
202:                // add the second address
203:                addSecondAddress(port);
204:
205:                // query addresses
206:                queryAddresses(port);
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.