== OpenDaylight controller library descriptions Shared functions and methods are compiled and bundled into libraries. This page describes client libraries. === C client library The C module generates the source code for the ANSI-C-compatible data structures and (de)serialization functions that can be used in conjunction with http://xmlsoft.org/[libxml2] to (de)serialize the REST resources as they are represented as XML data. The generated C source code depends on the http://xmlsoft.org/html/libxml-xmlreader.html[XML Reader API] and the http://xmlsoft.org/html/libxml-xmlwriter.html[XML Writer API] as well as the , , and C standard libraries. === REST XML example [literal] #include //... xmlTextReaderPtr reader = ...; //set up the reader to the url. full_ns0_edgeProps *response_element = ...; response_element = xml_read_full_ns0_edgeProps(reader); //handle the response as needed... //free the full_ns0_edgeProps free_full_ns0_edgeProps(response_element); === .NET client library The .NET client-side library defines the classes that can be (de)serialized to/from XML. This is useful for accessing the REST endpoints that are published by this application. ==== REST example [literal] //read a resource from a REST url Uri uri = new Uri(...); XmlSerializer s = new XmlSerializer( typeof( EdgeProps ) ); //Create the request object WebRequest req = WebRequest.Create(uri); WebResponse resp = req.GetResponse(); Stream stream = resp.GetResponseStream(); TextReader r = new StreamReader( stream ); EdgeProps order = (EdgeProps) s.Deserialize( r ); //handle the result as needed... This bundle contains C# source code. === Java client library The Java client-side library is used to access the Web service API for this application. The JAX-WS client-side library is used to provide the set of Java objects that can be serialized to/from XML using https://jaxb.dev.java.net/[JAXB]. This is useful for accessing the REST endpoints that are published by this application. ==== REST example (Raw JAXB) [literal] java.net.URL url = new java.net.URL(baseURL + "/{containerName}"); JAXBContext context = JAXBContext.newInstance( EdgeProps.class ); java.net.URLConnection connection = url.openConnection(); connection.connect(); Unmarshaller unmarshaller = context.createUnmarshaller(); EdgeProps result = (EdgeProps) unmarshaller.unmarshal( connection.getInputStream() ); //handle the result as needed... ==== REST example (Jersey client) [literal] com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(); EdgeProps result = client.resource(baseUrl + "/{containerName}") .get(EdgeProps.class); //handle the result as needed... === Java JSON client library The Java client-side library is used to provide the set of Java objects that can be serialized to/from JSON using Jackson. This is useful for accessing the JSON REST endpoints that are published by this application. ==== REST example (Raw Jackson) [literal] java.net.URL url = new java.net.URL(baseURL + "/{containerName}"); ObjectMapper mapper = new ObjectMapper(); java.net.URLConnection connection = url.openConnection(); connection.connect(); EdgeProps result = (EdgeProps) mapper.readValue( connection.getInputStream(), EdgeProps.class ); //handle the result as needed... === Objective C Client library The Objective C module generates the source code for the Objective C classes and (de)serialization functions that can be used in conjunction with http://xmlsoft.org/[libxml2] to (de)serialize the REST resources as they are represented as XML data. The generated Objective C source code depends on the http://xmlsoft.org/html/libxml-xmlreader.html[XML Reader API] and the http://xmlsoft.org/html/libxml-xmlwriter.html[XML Writer API] as well as the base OpenStep foundation classes. ==== REST XML example [literal] #import //... FULLNS0EdgeProps *responseElement; NSData *responseData; //data holding the XML from the response. NSURL *baseURL = ...; //the base url including the host and subpath. NSURL *url = [NSURL URLWithString: @"/{containerName}" relativeToURL: baseURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; NSURLResponse *response = nil; NSError *error = NULL; [request setHTTPMethod: @"GET"]; //this example uses a synchronous request, //but you'll probably want to use an asynchronous call responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; FULLNS0EdgeProps *responseElement = [FULLNS0EdgeProps readFromXML: responseData]; [responseElement retain]; //handle the response as needed...