FileDocCategorySizeDatePackage
saveBusiness.javaAPI DocExample3817Tue Oct 09 11:03:40 BST 2001com.ecerami.uddi

saveBusiness

public class saveBusiness extends Object
UDDI Program: publishes a new UDDI BusinessEntity record. Specify username and password on command line. Example usage: java saveBusiness ethan@ecerami.com password

Fields Summary
private AuthToken
token
private UDDIProxy
proxy
Constructors Summary
public saveBusiness(AuthToken token)
Constructor

param
token UDDI Authentication Token

    this.token = token;
  
Methods Summary
private BusinessEntitycreate_business()
Create new sample Business Entity record

    Vector businessEntities = new Vector();
    BusinessEntity businessEntity = new BusinessEntity("", "Acme Parts");

    //  Set Business Description
    businessEntity.setDefaultDescriptionString
      ("Maker of fine semiconductor parts");

    //  Set Contact Name and Email
    Contact contact = new Contact ("Ethan Cerami");
    Email email = new Email("cerami@cs.nyu.edu");
    Vector emailVector = new Vector();
    emailVector.addElement(email);
    contact.setEmailVector(emailVector);
    Contacts contacts = new Contacts();
    Vector contactVector = new Vector();
    contactVector.addElement(contact);
    contacts.setContactVector(contactVector);
    businessEntity.setContacts(contacts);
    return businessEntity;
  
public static voidmain(java.lang.String[] args)
Main Method

    saveBusiness publish = null;
    try {
        System.out.println("Saving New Business:  Acme Parts");
        AuthToken token = UDDIUtil.get_authentication_token(args[0], args[1]);
        System.out.println("Authentication Token:  "+token.getAuthInfoString());
        publish = new saveBusiness(token);
        String businessKey = publish.save_business();
        System.out.println("Published Business Key:  "+businessKey);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (SOAPException e) {
        e.printStackTrace();
    } catch (UDDIException e) {
        DispositionReport dr = e.getDispositionReport();
        UDDIUtil.printDispositionReport (dr);
        e.printStackTrace();
    }
  
public java.lang.Stringsave_business()
Save New Busines Entity

    String businessKey = null;

    //  Point to Microsoft Test Publish URL (SSL)
    proxy = new UDDIProxy();
    proxy.setPublishURL("https://test.uddi.microsoft.com/publish");

    //  Create Sample Business Entity Record
    BusinessEntity businessEntity = create_business ();
    Vector businessEntityVector = new Vector();
    businessEntityVector.addElement(businessEntity);

    //  Publish new Business Record
    BusinessDetail businessDetail =
      proxy.save_business(token.getAuthInfoString(), businessEntityVector);

    //  Verify publication by extracting new business key
    Vector businessEntities = businessDetail.getBusinessEntityVector();
    if (businessEntities.size() > 0) {
      BusinessEntity returnedBusinessEntity =
        (BusinessEntity)(businessEntities.elementAt(0));
      businessKey = returnedBusinessEntity.getBusinessKey();
    }
    return businessKey;