Sonatype Nexus Smart Proxy Plugin API

Introduction

The following items are available for download:

C Client Library

Created Sep 28, 2012 11:18:26 AM.

Introduction

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 libxml2 to (de)serialize the REST resources as they are represented as XML data.

The generated C source code depends on the XML Reader API and the XML Writer API as well as the <time.h>, <string.h>, and <stdlib.h> C standard libraries.

REST XML Example

#include <nexus-smartproxy-plugin.c> //... xmlTextWriterPtr writer = ...; //set up the writer to the url. nexus_smartproxy_plugin_ns0_configurePublishSubscribeRequestEnvelope *request_element = ...; xmlTextReaderPtr reader = ...; //set up the reader to the url. nexus_smartproxy_plugin_ns0_configurePublishSubscribeResponseEnvelope *response_element = ...; //set up the nexus_smartproxy_plugin_ns0_configurePublishSubscribeRequestEnvelope... xml_write_nexus_smartproxy_plugin_ns0_configurePublishSubscribeRequestEnvelope(writer, request_element); response_element = xml_read_nexus_smartproxy_plugin_ns0_configurePublishSubscribeResponseEnvelope(reader); //handle the response as needed... //free the nexus_smartproxy_plugin_ns0_configurePublishSubscribeRequestEnvelope free_nexus_smartproxy_plugin_ns0_configurePublishSubscribeRequestEnvelope(request_element); //free the nexus_smartproxy_plugin_ns0_configurePublishSubscribeResponseEnvelope free_nexus_smartproxy_plugin_ns0_configurePublishSubscribeResponseEnvelope(response_element);

Files

file size description
nexus-smartproxy-plugin.c 236.48K
enunciate-common.c 38.69K Common code needed for all projects.

.NET Client Library

Created Sep 28, 2012 11:18:27 AM for .NET 2.0.

Introduction

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

//read a resource from a REST url Uri uri = new Uri(...); XmlSerializer s = new XmlSerializer( typeof( ConfigurePublishSubscribeResponseEnvelope ) ); //Create the request object WebRequest req = WebRequest.Create(uri); WebResponse resp = req.GetResponse(); Stream stream = resp.GetResponseStream(); TextReader r = new StreamReader( stream ); ConfigurePublishSubscribeResponseEnvelope order = (ConfigurePublishSubscribeResponseEnvelope) s.Deserialize( r ); //handle the result as needed...

This bundle contains C# source code.

file size
nexus-smartproxy-plugin-dotnet.zip 1.85K

Java Client Library

Created Sep 28, 2012 11:18:28 AM for Java (Version 5+).

Introduction

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 JAXB. This is useful for accessing the REST endpoints that are published by this application.

REST Example (Raw JAXB)

java.net.URL url = new java.net.URL(baseURL + "/smartproxy/pub-sub/{repositoryId}"); JAXBContext context = JAXBContext.newInstance( ConfigurePublishSubscribeResponseEnvelope.class, ConfigurePublishSubscribeRequestEnvelope.class ); java.net.URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.connect(); Unmarshaller unmarshaller = context.createUnmarshaller(); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(configurePublishSubscribeRequestEnvelope, connection.getOutputStream()); ConfigurePublishSubscribeResponseEnvelope result = (ConfigurePublishSubscribeResponseEnvelope) unmarshaller.unmarshal( connection.getInputStream() ); //handle the result as needed...

REST Example (Jersey client)

com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(); ConfigurePublishSubscribeResponseEnvelope result = client.resource(baseUrl + "/smartproxy/pub-sub/{repositoryId}") .entity(configurePublishSubscribeRequestEnvelope) .put(ConfigurePublishSubscribeResponseEnvelope.class); //handle the result as needed...

Files

file size description
nexus-smartproxy-plugin-client.jar 14.81K The binaries for the Java client library.
nexus-smartproxy-plugin-client-sources.jar 10.11K The sources for the Java client library.

Objective C Client Library

Created Sep 28, 2012 11:18:26 AM.

Introduction

The Objective C module generates the source code for the Objective C classes and (de)serialization functions that can be used in conjunction with libxml2 to (de)serialize the REST resources as they are represented as XML data.

The generated Objective C source code depends on the XML Reader API and the XML Writer API as well as the base OpenStep foundation classes.

REST XML Example

#import <nexus-smartproxy-plugin.h> //... NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeRequestEnvelope *requestElement = [[NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeRequestEnvelope alloc] init]; NSData *requestData; //data holding the XML for the request. NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeResponseEnvelope *responseElement; NSData *responseData; //data holding the XML from the response. NSURL *baseURL = ...; //the base url including the host and subpath. NSURL *url = [NSURL URLWithString: @"/smartproxy/pub-sub/{repositoryId}" relativeToURL: baseURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; NSURLResponse *response = nil; NSError *error = NULL; [request setHTTPMethod: @"PUT"]; [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"]; //set up the NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeRequestEnvelope... requestData = [requestElement writeToXML]; [request setHTTPBody: requestData]; //this example uses a synchronous request, //but you'll probably want to use an asynchronous call responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeResponseEnvelope *responseElement = [NEXUS_SMARTPROXY_PLUGINNS0ConfigurePublishSubscribeResponseEnvelope readFromXML: responseData]; [responseElement retain]; //handle the response as needed...

Files

file size description
nexus-smartproxy-plugin.h 13.92K
nexus-smartproxy-plugin.m 148.62K
enunciate-common.h 12.22K Common header needed for all projects.
enunciate-common.m 41.77K Common implementation code needed for all projects.