import com.ibm.uddi.*;
import com.ibm.uddi.datatype.business.*;
import com.ibm.uddi.response.*;
import com.ibm.uddi.client.*;
import org.w3c.dom.Element;
import java.util.Vector;
import java.util.Properties;


public class SaveBusinessExample {
   public static void main (String args[]) {
      SaveBusinessExample app = new SaveBusinessExample();
      app.run();
      System.exit(0);
   }

   public void run() {
      UDDIProxy proxy = new UDDIProxy();

      try {
         // The following values point to the GCoC Yamato Priate UDDI site
         proxy.setInquiryURL("http://dtco02:9080/uddisoap/inquiryapi");
         proxy.setPublishURL("http://dtco02:9080/uddisoap/publishapi");
       
      } catch (Exception e) {
         e.printStackTrace();
      }
      try {

         // Get an authorization token
         System.out.println("\nGet authtoken");
         
         // Pass in userid and password registered at the UDDI site
         AuthToken token = proxy.get_authToken("userid",
                                               "password" );

         // Create minimum required data objects
         Vector entities = new Vector();

         // business name
         BusinessEntity be = new BusinessEntity("", "日本の会社");
         // multi lanauge data is added here.   
         entities.addElement(be);

         // Save business
         BusinessDetail bd = proxy.save_business(token.getAuthInfoString(),entities);

      // Handle possible errors
      } catch (UDDIException e) {
         DispositionReport dr = e.getDispositionReport();
         if (dr!=null) {
            System.out.println("UDDIException faultCode:" + e.getFaultCode() +
                               "\n operator:" + dr.getOperator() +
                               "\n generic:"  + dr.getGeneric() +
                               "\n errno:"    + dr.getErrno() +
                               "\n errCode:"  + dr.getErrCode() +
                               "\n errInfoText:" + dr.getErrInfoText());
         }
         e.printStackTrace();

      // Catch any other exception that may occur
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}