Source Code Cross Referenced for UddiPing.java in  » IDE-Netbeans » usersguide » mypackage » 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 » IDE Netbeans » usersguide » mypackage 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005 Sun Microsystems, Inc.  All rights reserved.  U.S.
003:         * Government Rights - Commercial software.  Government users are subject
004:         * to the Sun Microsystems, Inc. standard license agreement and
005:         * applicable provisions of the FAR and its supplements.  Use is subject
006:         * to license terms.
007:         *
008:         * This distribution may include materials developed by third parties.
009:         * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
010:         * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
011:         * other countries.
012:         *
013:         * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
014:         *
015:         * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
016:         * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
017:         * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
018:         * en vigueur de la FAR (Federal Acquisition Regulations) et des
019:         * supplements a celles-ci.  Distribue par des licences qui en
020:         * restreignent l'utilisation.
021:         *
022:         * Cette distribution peut comprendre des composants developpes par des
023:         * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
024:         * sont des marques de fabrique ou des marques deposees de Sun
025:         * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
026:         */
027:
028:        package mypackage;
029:
030:        import javax.xml.soap.*;
031:        import java.net.*;
032:        import java.util.*;
033:        import java.io.*;
034:
035:        public class UddiPing {
036:            public static void main(String[] args) {
037:                try {
038:                    // two arguments are passed in from build.xml
039:                    if (args.length != 2) {
040:                        System.err.println("Usage: asant run "
041:                                + "-Dbusiness-name=<name>");
042:                        System.exit(1);
043:                    }
044:
045:                    // Retrieve settings from uddi.properties file,
046:                    // add to system properties
047:                    Properties myprops = new Properties();
048:                    myprops.load(new FileInputStream(args[0]));
049:
050:                    Properties props = System.getProperties();
051:
052:                    Enumeration propNames = myprops.propertyNames();
053:                    while (propNames.hasMoreElements()) {
054:                        String s = (String) propNames.nextElement();
055:                        props.setProperty(s, myprops.getProperty(s));
056:                    }
057:
058:                    // Create connection, message factory, and
059:                    // SOAP factory
060:                    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory
061:                            .newInstance();
062:                    SOAPConnection connection = soapConnectionFactory
063:                            .createConnection();
064:                    MessageFactory messageFactory = MessageFactory
065:                            .newInstance();
066:                    SOAPFactory soapFactory = SOAPFactory.newInstance();
067:
068:                    // Create a message
069:                    SOAPMessage message = messageFactory.createMessage();
070:
071:                    // Get the SOAP header from the message and remove it
072:                    SOAPHeader header = message.getSOAPHeader();
073:                    header.detachNode();
074:
075:                    // Get the SOAP body from the message
076:                    SOAPBody body = message.getSOAPBody();
077:
078:                    // Create a UDDI v2 find_business body element
079:                    SOAPBodyElement findBusiness = body
080:                            .addBodyElement(soapFactory.createName(
081:                                    "find_business", "", "urn:uddi-org:api_v2"));
082:                    findBusiness.addAttribute(
083:                            soapFactory.createName("generic"), "2.0");
084:                    findBusiness.addAttribute(
085:                            soapFactory.createName("maxRows"), "100");
086:
087:                    SOAPElement businessName = findBusiness
088:                            .addChildElement(soapFactory.createName("name"));
089:                    businessName.addTextNode(args[1]);
090:
091:                    message.saveChanges();
092:
093:                    // Display the message you are sending
094:                    System.out.println("\n----- Request Message ----\n");
095:                    message.writeTo(System.out);
096:
097:                    // Retrieve the endpoint from system properties
098:                    URL endpoint = new URL(System.getProperties().getProperty(
099:                            "URL"));
100:
101:                    // Send message and get reply
102:                    SOAPMessage reply = connection.call(message, endpoint);
103:
104:                    System.out.println("\n\nReceived reply from: " + endpoint);
105:                    System.out.println("\n------ Reply Message -----\n");
106:
107:                    // Display the reply
108:                    reply.writeTo(System.out);
109:
110:                    // Now parse the reply
111:                    SOAPBody replyBody = reply.getSOAPBody();
112:
113:                    /*
114:                     * The response to a find_business query is a
115:                     * businessList conformant to the UDDI V2 Data
116:                     * Structure specifications. For further details,
117:                     * see
118:                     * http://uddi.org/pubs/DataStructure-V2.03-Published-20020719.htm#_Toc25130802
119:                     */
120:                    System.out.println("\n\nContent extracted from "
121:                            + "the reply message:\n");
122:
123:                    Iterator businessListIterator = replyBody
124:                            .getChildElements(soapFactory.createName(
125:                                    "businessList", "", "urn:uddi-org:api_v2"));
126:
127:                    /*
128:                     * businessList is a mandatory element in a
129:                     * successful response and appears only once.
130:                     */
131:                    SOAPBodyElement businessList = (SOAPBodyElement) businessListIterator
132:                            .next();
133:
134:                    /*
135:                     * Get the businessInfos element. This contains
136:                     * the business entries retrieved that match the
137:                     * criteria specified in the find_business
138:                     * request.
139:                     */
140:                    Iterator businessInfosIterator = businessList
141:                            .getChildElements(soapFactory.createName(
142:                                    "businessInfos", "", "urn:uddi-org:api_v2"));
143:
144:                    /*
145:                     * businessInfos, too is a mandatory element in
146:                     * a successful response and appears only once.
147:                     */
148:                    SOAPElement businessInfos = (SOAPElement) businessInfosIterator
149:                            .next();
150:
151:                    /*
152:                     * The businessInfos contains zero or more
153:                     * businessInfo structures. Each businessInfo
154:                     * structure contains the company name and
155:                     * optional description data.
156:                     */
157:                    Iterator businessInfoIterator = businessInfos
158:                            .getChildElements(soapFactory.createName(
159:                                    "businessInfo", "", "urn:uddi-org:api_v2"));
160:
161:                    if (!businessInfoIterator.hasNext()) {
162:                        System.out.println("No businesses found "
163:                                + "matching the name \"" + args[1] + "\".");
164:                    } else {
165:                        while (businessInfoIterator.hasNext()) {
166:                            SOAPElement businessInfo = (SOAPElement) businessInfoIterator
167:                                    .next();
168:
169:                            // Extract name and description from the 
170:                            // businessInfo
171:                            Iterator nameIterator = businessInfo
172:                                    .getChildElements(soapFactory.createName(
173:                                            "name", "", "urn:uddi-org:api_v2"));
174:
175:                            while (nameIterator.hasNext()) {
176:                                businessName = (SOAPElement) nameIterator
177:                                        .next();
178:                                System.out.println("Company name: "
179:                                        + businessName.getValue());
180:                            }
181:
182:                            Iterator descriptionIterator = businessInfo
183:                                    .getChildElements(soapFactory.createName(
184:                                            "description", "",
185:                                            "urn:uddi-org:api_v2"));
186:
187:                            while (descriptionIterator.hasNext()) {
188:                                SOAPElement businessDescription = (SOAPElement) descriptionIterator
189:                                        .next();
190:                                System.out.println("Description: "
191:                                        + businessDescription.getValue());
192:                            }
193:
194:                            System.out.println("");
195:                        }
196:                    }
197:
198:                    // Close the connection
199:                    connection.close();
200:                } catch (Exception ex) {
201:                    ex.printStackTrace();
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.