Wednesday, December 21, 2011

Access data from a WITSML server


     import java.net.MalformedURLException;
     import java.net.URL;
     import java.util.List;

     import org.jwitsml.Capabilities;
     import org.jwitsml.WitsmlQuery;
     import org.jwitsml.WitsmlServer;
     import org.jwitsml.WitsmlServerException;
     import org.jwitsml.WitsmlVersion;
     import org.jwitsml.WitsmlWell;

     public class BasicExample {
       public static void main(String[] arguments) {
         try {
           // Identify ourself and our capabilities as WITSML client

           Capabilities clientCapabilities = new Capabilities(WitsmlVersion.VERSION_1_3_1,
                                                              "First And Lastname",
                                                              "e-mail@some.org",
                                                              "+12 34 56 789",
                                                              "Description",
                                                              "Application Name",
                                                              "Vendor",
                                                              "Version Number");
           
           // Establish URL to the server
           URL url = new URL("http://path/to/witsml/server");
           
           // Create the WITSML server instance
           WitsmlServer witsmlServer = new WitsmlServer(url, "userName", "password",
                                                        WitsmlVersion.VERSION_1_3_1,
                                                        clientCapabilities);
           
           // Retrieve all wells
           List<WitsmlWell> wells = witsmlServer.get(WitsmlWell.class,
                                                     new WitsmlQuery());
           
           // Write well names to the console
           for (WitsmlWell well : wells)
             System.out.println(well.getName());
         }
         catch (MalformedURLException exception) {
           exception.printStackTrace();
         }
         catch (WitsmlServerException exception) {
           exception.printStackTrace();
         }
       }
     }
  

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...