1 9 10 import java.util.Properties ; 11 import java.util.Vector ; 12 13 import org.uddi4j.UDDIException; 14 import org.uddi4j.client.UDDIProxy; 15 import org.uddi4j.datatype.Name; 16 import org.uddi4j.response.AuthToken; 17 import org.uddi4j.response.BusinessInfo; 18 import org.uddi4j.response.BusinessList; 19 import org.uddi4j.response.DispositionReport; 20 import org.uddi4j.response.Result; 21 import org.uddi4j.util.FindQualifier; 22 import org.uddi4j.util.FindQualifiers; 23 24 36 public class DeleteBusinessExample 37 { 38 39 Properties config = null; 40 41 public static void main (String args[]) 42 { 43 DeleteBusinessExample app = new DeleteBusinessExample(); 44 System.out.println("\n*********** Running DeleteBusinessExample ***********"); 45 app.run(); 46 System.exit(0); 47 } 48 49 public void run() 50 { 51 config = Configurator.load(); 53 54 UDDIProxy proxy = new UDDIProxy(); 56 try 57 { 58 proxy.setInquiryURL(config.getProperty("inquiryURL")); 60 proxy.setPublishURL(config.getProperty("publishURL")); 61 62 System.out.println("\nGet authtoken"); 64 65 AuthToken token = proxy.get_authToken(config.getProperty("userid"), 67 config.getProperty("password")); 68 69 System.out.println("Returned authToken:" + token.getAuthInfoString()); 70 71 System.out.println("Search for '" + config.getProperty("businessName") + "' to delete"); 72 73 Vector names = new Vector (); 75 names.add(new Name(config.getProperty("businessName"))); 76 77 FindQualifiers findQualifiers = new FindQualifiers(); 79 Vector qualifier = new Vector (); 80 qualifier.add(new FindQualifier("caseSensitiveMatch")); 81 findQualifiers.setFindQualifierVector(qualifier); 82 83 BusinessList businessList = proxy.find_business(names, null, null, null,null,findQualifiers,5); 86 87 Vector businessInfoVector = businessList.getBusinessInfos().getBusinessInfoVector(); 88 89 for( int i = 0; i < businessInfoVector.size(); i++ ) 93 { 94 BusinessInfo bi = (BusinessInfo)businessInfoVector.elementAt(i); 95 System.out.println("Found business key:" + bi.getBusinessKey()); 96 97 DispositionReport dr = proxy.delete_business(token.getAuthInfoString(), 99 bi.getBusinessKey()); 100 101 if( dr.success() ) 102 { 103 System.out.println("Business successfully deleted"); 104 } 105 else 106 { 107 System.out.println(" Error during deletion of Business\n"+ 108 "\n operator:" + dr.getOperator() + 109 "\n generic:" + dr.getGeneric() ); 110 111 Vector results = dr.getResultVector(); 112 for( int j=0; j<results.size(); j++ ) 113 { 114 Result r = (Result)results.elementAt(j); 115 System.out.println("\n errno:" + r.getErrno() ); 116 if( r.getErrInfo()!=null ) 117 { 118 System.out.println("\n errCode:" + r.getErrInfo().getErrCode() + 119 "\n errInfoText:" + r.getErrInfo().getText()); 120 } 121 } 122 } 123 } 124 } 125 catch( UDDIException e ) 127 { 128 DispositionReport dr = e.getDispositionReport(); 129 if( dr!=null ) 130 { 131 System.out.println("UDDIException faultCode:" + e.getFaultCode() + 132 "\n operator:" + dr.getOperator() + 133 "\n generic:" + dr.getGeneric() ); 134 135 Vector results = dr.getResultVector(); 136 for( int i=0; i<results.size(); i++ ) 137 { 138 Result r = (Result)results.elementAt(i); 139 System.out.println("\n errno:" + r.getErrno() ); 140 if( r.getErrInfo()!=null ) 141 { 142 System.out.println("\n errCode:" + r.getErrInfo().getErrCode() + 143 "\n errInfoText:" + r.getErrInfo().getText()); 144 } 145 } 146 } 147 e.printStackTrace(); 148 } 149 catch( Exception e ) 151 { 152 e.printStackTrace(); 153 } 154 } 155 } 156 157 | Popular Tags |