?? 13.txt
字號:
例程13-1
01 import com.ibm.uddi.*;
02 import com.ibm.uddi.datatype.business.*;
03 import com.ibm.uddi.response.*;
04 import com.ibm.uddi.client.*;
05 import org.w3c.dom.Element;
06 import java.util.Vector;
07 import java.util.Properties;
08
09 /**
10 * Very simple use of UDDI API. Invoke a inquiry API to
11 * find all businesses starting with "S".
12 */
13 public class FindBusinessExample {
14 public static void main (String args[]) {
15
16 FindBusinessExample app = new FindBusinessExample();
17 app.run();
18 System.exit(0);
19 }
20
21 public void run() {
22 // Construct a UDDIProxy object. Enables SSL support
23 UDDIProxy proxy = new UDDIProxy();
24
25 try {
26 // Select the desired UDDI server node
27
28 // The following values point to the IBM UDDI test site
29 proxy.setInquiryURL("http://www-3.ibm.com/services/uddi/testregistry/inquiryapi");
30 // proxy.setPublishURL(
31 // "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi");
32 // The following values point to the IBM UDDI test site
33 // proxy.setInquiryURL("http://www-3.ibm.com/services/uddi/inquiryapi");
34 // proxy.setPublishURL(
35 // "https://www-3.ibm.com/services/uddi/protect/publishapi");
36 // The following values point to the Microsoft UDDI test site
37 // proxy.setInquiryURL("http://test.uddi.microsoft.com/inquire");
38 // proxy.setPublishURL("https://test.uddi.microsoft.com/publish");
39
40 // The following values point to the Microsoft UDDI official site
41 // proxy.setInquiryURL("http://uddi.microsoft.com/inquire");
42 // proxy.setPublishURL("https://uddi.microsoft.com/publish");
43
44 // The following values for a locally installed test server
45 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
46 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
47
48 } catch (Exception e) {
49 e.printStackTrace();
50 }
51 try {
52
53 // Find businesses who's name starts with S
54 BusinessList bl = proxy.find_business("S", null, 0);
55
56 Vector businessInfoVector = bl.getBusinessInfos().getBusinessInfoVector();
57 for (int i = 0; i < businessInfoVector.size(); i++) {
58 BusinessInfo businessInfo =
59 (BusinessInfo)businessInfoVector.elementAt(i);
60 // Print name for each business
61 System.out.println(businessInfo.getNameString());
62 }
63
64 // Handle possible errors
65 } catch (UDDIException e) {
66 DispositionReport dr = e.getDispositionReport();
67 if (dr!=null) {
68 System.out.println("UDDIException faultCode:" + e.getFaultCode() +
69 "\n operator:" + dr.getOperator() +
70 "\n generic:" + dr.getGeneric() +
71 "\n errno:" + dr.getErrno() +
72 "\n errCode:" + dr.getErrCode() +
73 "\n errInfoText:" + dr.getErrInfoText());
74 }
75 e.printStackTrace();
76
77 // Catch any other exception that may occur
78 } catch (Exception e) {
79 e.printStackTrace();
80 }
81 }
82 }
例程13-2
001 import com.ibm.uddi.*;
002 import com.ibm.uddi.datatype.business.*;
003 import com.ibm.uddi.response.*;
004 import com.ibm.uddi.client.*;
005 import org.w3c.dom.Element;
006 import java.util.Vector;
007 import java.util.Properties;
008
009 /**
010 * Sample code that exercises the publish API. Attempts
011 * to save a business named 'Sample Business'.
012 *
013 * <OL>
014 * <LI>Sets up a UDDIProxy object
015 * <LI>Requests an authorization token
016 * <LI>Saves a business named "Sample Business"
017 * <LI>Lists businesses starting with S. The new
018 * business should be in the list.
019 * </OL>
020 */
021 public class SaveBusinessExample {
022 public static void main (String args[]) {
023 /*****************************************************************/
024 /* Comment out the following lines to disable SSL and HTTPS support
025 * or if using a different SSL provider.
026 * JSSE must be in the classpath to use or compile these lines.
027 */
028 System.setProperty("java.protocol.handler.pkgs",
029 "com.ibm.net.ssl.internal.www.protocol");
030 java.security.Security.addProvider(new com.ibm.jsse.JSSEProvider());
031 /*****************************************************************/
032
033 SaveBusinessExample app = new SaveBusinessExample();
034 app.run();
035 System.exit(0);
036 }
037
038 public void run() {
039 // Construct a UDDIProxy object
040 UDDIProxy proxy = new UDDIProxy();
041
042 try {
043 // Select the desired UDDI server node
044
045 // The following values point to the IBM UDDI test site
046 proxy.setInquiryURL(
047 "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi");
048 proxy.setPublishURL(
049 "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi");
050 // The following values point to the IBM UDDI official site
051 // proxy.setInquiryURL("http://www-3.ibm.com/services/uddi/inquiryapi");
052 // proxy.setPublishURL(
053 // "https://www-3.ibm.com/services/uddi/protect/publishapi");
054 // The following values point to the Microsoft UDDI test site
055 // proxy.setInquiryURL("http://test.uddi.microsoft.com/inquire");
056 // proxy.setPublishURL("https://test.uddi.microsoft.com/publish");
057
058 // The following values point to the Microsoft UDDI official site
059 // proxy.setInquiryURL("http://uddi.microsoft.com/inquire");
060 // proxy.setPublishURL("https://uddi.microsoft.com/publish");
061
062 // The following values for a locally installed test server
063 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
064 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
065 } catch (Exception e) {
066 e.printStackTrace();
067 }
068 try {
069
070 // Get an authorization token
071 System.out.println("\nGet authtoken");
072
073 // Pass in userid and password registered at the UDDI site
074 AuthToken token = proxy.get_authToken("userid",
075 "password" );
076
077 System.out.println("Returned authToken:" + token.getAuthInfoString());
078
079 System.out.println("\nSave 'Sample business'");
080
081 // Create minimum required data objects
082 Vector entities = new Vector();
083
084 // Create a new business entity using required elements constructor
085 // Name is the business name. BusinessKey must be "" to save a new
086 // business
087 BusinessEntity be = new BusinessEntity("", "Sample Business");
088 entities.addElement(be);
089
090 // Save business
091 BusinessDetail bd = proxy.save_business(token.getAuthInfoString(),entities);
092
093 // Process returned BusinessDetail object
094 Vector businessEntities = bd.getBusinessEntityVector();
095 BusinessEntity returnedBusinessEntity =
096 (BusinessEntity)(businessEntities.elementAt(0));
097 System.out.println("Returned businessKey:" +
098 returnedBusinessEntity.getBusinessKey());
099
100 System.out.println(
101 "\nListing businesses starting with S after we publish");
102
103 // Find businesses who's name starts with S
104 BusinessList bl = proxy.find_business("S", null, 0);
105
106 Vector businessInfoVector = bl.getBusinessInfos().getBusinessInfoVector();
107 for (int i = 0; i < businessInfoVector.size(); i++) {
108 BusinessInfo businessInfo = (BusinessInfo)businessInfoVector.elementAt(i);
109 System.out.println(businessInfo.getNameString());
110 }
111
112 // Handle possible errors
113 } catch (UDDIException e) {
114 DispositionReport dr = e.getDispositionReport();
115 if (dr!=null) {
116 System.out.println("UDDIException faultCode:" + e.getFaultCode() +
117 "\n operator:" + dr.getOperator() +
118 "\n generic:" + dr.getGeneric() +
119 "\n errno:" + dr.getErrno() +
120 "\n errCode:" + dr.getErrCode() +
121 "\n errInfoText:" + dr.getErrInfoText());
122 }
123 e.printStackTrace();
124
125 // Catch any other exception that may occur
126 } catch (Exception e) {
127 e.printStackTrace();
128 }
129 }
130 }
例程13-3
001 import com.ibm.uddi.*;
002 import com.ibm.uddi.datatype.business.*;
003 import com.ibm.uddi.response.*;
004 import com.ibm.uddi.client.*;
005 import org.w3c.dom.Element;
006 import java.util.Vector;
007 import java.util.Properties;
008
009 /**
010 * Sample code that exercises the publish API. Attempts
011 * to delete a business named 'Sample Business'.
012 * <ol>
013 * <li>Performs an inquiry to find this business
014 * <li>get_authToken to login to server
015 * <li>delete any businesses with key found in step 1.
016 * </ol>
017 */
018 public class DeleteBusinessExample {
019 public static void main (String args[]) {
020 /*****************************************************************/
021 /* Comment out the following lines to disable SSL and HTTPS support
022 * or if using a different SSL provider.
023 * JSSE must be in the classpath to use or compile these lines.
024 */
025 System.setProperty("java.protocol.handler.pkgs",
026 "com.ibm.net.ssl.internal.www.protocol");
027 java.security.Security.addProvider(new com.ibm.jsse.JSSEProvider());
028 /*****************************************************************/
029
030 DeleteBusinessExample app = new DeleteBusinessExample();
031 app.run();
032 System.exit(0);
033 }
034
035 public void run() {
036 // Construct a UDDIProxy object. Enables SSL support
037 UDDIProxy proxy = new UDDIProxy();
038
039 try {
040 // Select the desired UDDI server node
041 // The following values point to the IBM UDDI test site
042 proxy.setInquiryURL(
043 "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi");
044 proxy.setPublishURL(
045 "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi");
046 // The following values point to the IBM UDDI official site
047 // proxy.setInquiryURL("http://www-3.ibm.com/services/uddi/inquiryapi");
048 // proxy.setPublishURL(
049 // "https://www-3.ibm.com/services/uddi/protect/publishapi");
050 // The following values point to the Microsoft UDDI test site
051 // proxy.setInquiryURL("http://test.uddi.microsoft.com/inquire");
052 // proxy.setPublishURL("https://test.uddi.microsoft.com/publish");
053
054 // The following values point to the Microsoft UDDI official site
055 // proxy.setInquiryURL("http://uddi.microsoft.com/inquire");
056 // proxy.setPublishURL("https://uddi.microsoft.com/publish");
057
058 // The following values for a locally installed test server
059 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
060 // proxy.setInquiryURL("http://localhost:8080/services/uddi/servlet/uddi");
061
062 } catch (Exception e) {
063 e.printStackTrace();
064 }
065 try {
066
067 // Get an authorization token
068 System.out.println("\nGet authtoken");
069
070 // Pass in userid and password registered at the UDDI site
071 AuthToken token = proxy.get_authToken("userid",
072 "password" );
073
074 System.out.println("Returned authToken:" + token.getAuthInfoString());
075
076 System.out.println("Search for 'Sample business' to delete");
077
078 // Find businesses starting with 'Sample business'
079 BusinessList bl = proxy.find_business("Sample business", null, 0);
080
081 Vector businessInfoVector = bl.getBusinessInfos().getBusinessInfoVector();
082
083 // Try to delete any businesses with this name. Multiple businesses with the
084 // same name may have been created by different userids. Delete will fail for
085 // businesses not created by this id
086 for (int i = 0; i < businessInfoVector.size(); i++) {
087 BusinessInfo bi = (BusinessInfo)businessInfoVector.elementAt(i);
088 System.out.println("Found business key:" + bi.getBusinessKey());
089
090 // Have found the matching business key, delete using the authToken
091 DispositionReport dr = proxy.delete_business(token.getAuthInfoString(),
092 bi.getBusinessKey());
093
094 if (dr.success()) {
095 System.out.println("Business successfully deleted");
096 } else {
097 System.out.println("Errno:" + dr.getErrno() +
098 "\n ErrCode:" + dr.getErrCode() +
099 "\n ErrText:" + dr.getErrInfoText() );
100 }
101 }
102
103 // Handle possible errors
104 } catch (UDDIException e) {
105 DispositionReport dr = e.getDispositionReport();
106 if (dr!=null) {
107 System.out.println("UDDIException faultCode:" + e.getFaultCode() +
108 "\n operator:" + dr.getOperator() +
109 "\n generic:" + dr.getGeneric() +
110 "\n errno:" + dr.getErrno() +
111 "\n errCode:" + dr.getErrCode() +
112 "\n errInfoText:" + dr.getErrInfoText());
113 }
114 e.printStackTrace();
115
116 // Catch any other exception that may occur
117 } catch (Exception e) {
118 e.printStackTrace();
119 }
120 }
121 }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -