Explore Public Snippets
Found 617 snippets matching: "web service"
public by fabio.nosenzo @ Amazon_AWS_Python_API 588165 5 8 -1
Amazon S3 Aws - S3Connection object from python boto API
import boto.utils from boto.connection import AWSAuthConnection class S3Connection(AWSAuthConnection): DefaultHost = boto.config.get('s3', 'host', 's3.amazonaws.com') DefaultCallingFormat = boto.config.get('s3', 'calling_format', 'boto.s3.connection.SubdomainCallingFormat') QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s' def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, host=DefaultHost, debug=0, https_connection_factory=None, calling_format=DefaultCallingFormat, path='/', provider='aws', bucket_class=Bucket, security_token=None, suppress_consec_slashes=True, anon=False, validate_certs=None): if isinstance(calling_format, str): calling_format=boto.utils.find_class(calling_format)() self.calling_format = calling_format self.bucket_class = bucket_class self.anon = anon AWSAuthConnection.__init__(self, host, aws_access_key_id, aws_secret_access_key, is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, debug=debug, https_connection_factory=https_connection_factory, path=path, provider=provider, security_token=security_token, suppress_consec_slashes=suppress_consec_slashes, validate_certs=validate_certs)
public by cghersi 468641 7 8 2
Load a SOAP endpoint with Apache CXF using JMS transport provided by Apache ActiveMQ
private JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); public MyInterface loadEndPoint() { //try to load from local, if available: boolean loadOK = false; MyInterface result = null; try { Class<?> c = Class.forName("MyImplClass"); Method fact = c.getMethod("get"); result = (MyInterface) fact.invoke(null); loadOK = true; } catch (ClassNotFoundException e) { log.info("Cannot find MyImplClass, redirecting to remote access...", e); } catch (Exception e) { log.warn("Error searching MyImplClass, , redirecting to remote access. Exception is " + e, e); } //load remote endpoint: if (!loadOK) { //detect transport protocol for web services: String brokerAddr = "127.0.0.1"; //the right broker address String queueName = "MyQueueName"; String address = "jms:jndi:dynamicQueues/" + queueName + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=" + brokerAddr; log.info("Connecting to " + address); String connString = "tcp://" + brokerAddr + ":61616"; ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory("Myusername", "Mypassword", connString); SoapBindingConfiguration conf = new SoapBindingConfiguration(); //MTOM not supported! .net does not interoperate with cxf mtom impl. // conf.setMtomEnabled(true); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.setServiceClass(MyInterface.class); factory.setAddress(address); factory.getFeatures().add(new WSAddressingFeature()); factory.getFeatures().add(getJMSConfigFeature(queueName, connFactory, 10000))); Object resObj = factory.create(); if ((resObj != null) && (resObj instanceof MyInterface)) result = (MyInterface) resObj; } return result; } } public static JMSConfigFeature getJMSConfigFeature(String queueName, ActiveMQConnectionFactory connectionFactory, Long receiveTimeout) { JMSConfigFeature jmsConfigFeature = new JMSConfigFeature(); JMSConfiguration jmsConfig = new JMSConfiguration(); jmsConfig.setUseJms11(true); jmsConfig.setTargetDestination(queueName); jmsConfig.setConnectionFactory(connectionFactory); if (receiveTimeout != null) jmsConfig.setReceiveTimeout(receiveTimeout); jmsConfigFeature.setJmsConfig(jmsConfig); return jmsConfigFeature; }
public by lbottaro @ Amazon_AWS_Python_API 304434 0 8 0
Amazon S3 Aws - How to download a file from a bucket to a target directory
# This downloads the object foobar.pdf and saves it in /home/luca/documents/ key = bucket.get_key('foobar.pdf') key.get_contents_to_filename('/home/luca/documents/foobar.pdf')
public by dave83 2730 0 6 3
JAX-RS web service using Path annotation
import javax.ws.*; @Path("/path") public class WebRestService { @GET public Response getUser() { return Response.status(200).entity("get User is called").build(); } @GET @Path("/test") public Response getTest() { return Response.status(200).entity("get Test is called").build(); } }
public by lbottaro @ Amazon_AWS_Python_API 10726 32 8 0
Amazon S3 Aws - Change an object's acl using boto API
# Public ACL example # Here you get the key reference for file foo_bar.txt foo_bar_key = bucket.get_key('foo_bar.txt') # This set the foo_bar file publicly readable foo_bar_key.set_canned_acl('public-read') # Private ACL example # Here you get the key reference for file secret.txt secret_key = bucket.get_key('secret.txt') # This set the secret.txt file as private secret_key.set_canned_acl('private')
public by lbottaro @ Amazon_AWS_Python_API 6432 19 8 1
Amazon S3 Aws - How to delete a bucket using boto API
import boto import boto.s3.connection access_key = '<aws access key>' secret_key = '<aws secret key>' # This code initialize the Amazon S3 connection to your account conn = boto.connect_s3( aws_access_key_id = access_key, aws_secret_access_key = secret_key) # Iteration through all available buckets stored into S3 # Name and creation date are listed for bucket in conn.get_all_buckets(): print "{name}\t{created}".format( name = bucket.name, created = bucket.creation_date, ) # Remove the bucket conn.delete_bucket(bucket.name)
public by lbottaro @ Amazon_AWS_Python_API 6270 3 8 0
Amazon S3 Aws - How to get content information for a given bucket using boto python api
import boto import boto.s3.connection access_key = '<aws access key>' secret_key = '<aws secret key>' # This code initialize the Amazon S3 connection to your account conn = boto.connect_s3( aws_access_key_id = access_key, aws_secret_access_key = secret_key) # Iteration through all available buckets stored into S3 # Name and creation date are listed for bucket in conn.get_all_buckets(): print "{name}\t{created}".format( name = bucket.name, created = bucket.creation_date, ) # For each bucket get all data content put into the bucket for key in bucket.list(): # Get name, size and date print "{name}\t{size}\t{modified}".format( name = key.name, size = key.size, modified = key.last_modified, )
public by lbottaro @ Amazon_AWS_Python_API 6135 1 8 1
Amazon S3 Aws - get_bucket method in boto python API
from boto.s3.connection import S3Connection from boto.s3.key import Key # Get connection using Amazon secret and access keys conn = S3Connection('<aws secret key>', '<aws access key>') # Get the bucket with name 'bucketname' bucket = conn.get_bucket('bucketname') # Get the key reference to file 'picture.jpg' key = bucket.get_key("picture.jpg") # Open file in write mode fp = open ("picture.jpg", "w") # Set the reference to file key.get_file (fp)
public by lbottaro @ Amazon_AWS_Python_API 5977 1 8 1
Amazon S3 Aws - Generate signed object download URLs
# Get the private key reference to secret_plans.txt file plans_key = bucket.get_key('secret_plans.txt') # Generate a signed URL, timer is set to 1 hour plans_url = plans_key.generate_url(3600, query_auth=True, force_http=True) print plans_url
public by lbottaro @ Amazon_AWS_Python_API 5467 5 8 1
Amazon S3 Aws - Generate unsigned object download URLs
# Create an unsigned download URL for hello.txt. # Requirements: # file hello.txt is public by setting its ACL # Get hello.txt file key from bucket hello_key = bucket.get_key('hello.txt') # Create the unsigned URL hello_url = hello_key.generate_url(0, query_auth=False, force_http=True) print hello_url