coldfusion_为您服务的ColdFusion 9:使用AIR进行图像处理

coldfusion

Earlier this month, Adobe released the latest version of ColdFusion at the MAX conference in Los Angeles. Back in July I gave an overview of ColdFusion 9, covering some of the new features with the benefit of Kay Smoljak’s examples. This article is about one juicy new feature that we omitted in that article: ColdFusion as a service (CFaaS).

本月初,Adobe在洛杉矶的MAX会议上发布了最新版本的ColdFusion。 早在7月,我就对ColdFusion 9进行了概述,并借助Kay Smoljak的示例介绍了一些新功能。 本文是关于我们在该文章中省略的一个多汁的新功能:ColdFusion即服务(CFaaS)。

CFaaS is a new way of accessing some of ColdFusion’s functionalities as remote or local services. For example, <CFIMAGE> and <CFDOCUMENT>, which were previously only available as CFML tags and could therefore only be used in .cfm documents running on your server. With CFaaS, your client-side code can access these ColdFusion functionalities with web service calls.

CFaaS是一种访问ColdFusion的某些功能(作为远程或本地服务)的新方法。 例如, <CFIMAGE><CFDOCUMENT>以前只能用作CFML标记,因此只能在服务器上运行的.cfm文档中使用。 使用CFaaS,您的客户端代码可以通过Web服务调用访问这些ColdFusion功能。

With the current trend towards richer applications based on Flash, Flex, AIR, or AJAX on the client side, it made sense for Adobe to give ColdFusion 9 a service layer. This allows RIA developers to leverage some of ColdFusion’s rapid application development functionality in their work.

当前趋势是在客户端基于基于Flash,Flex,AIR或AJAX的功能更丰富的应用程序,因此Adobe为ColdFusion 9提供服务层是很有意义的。 这使RIA开发人员可以在工作中利用ColdFusion的某些快速应用程序开发功能。

To illustrate how you can take advantage of this new service layer, I’ll show you how to build a simple AIR application that will act as a front end for image processing tasks taking place on the server side. We want to be able to drag and drop an image into the application, upload it to a ColdFusion server, perform some CFaaS functionality to modify the image, then retrieve the image to be displayed in our application. Finally, users will be able to drag and drop the modified image back into their file system as a JPEG file.

为了说明如何利用这一新的服务层,我将向您展示如何构建一个简单的AIR应用程序,该应用程序将充当服务器端发生的图像处理任务的前端。 我们希望能够将图像拖放到应用程序中,将其上传到ColdFusion服务器,执行一些CFaaS功能来修改图像,然后检索要在我们的应用程序中显示的图像。 最后,用户将能够将修改后的图像作为JPEG文件拖放回其文件系统中。

Before we start, here’s what you’ll need:

在开始之前,这是您需要的:

  • ColdFusion 9 from Adobe. Download and install the free developer edition.

    来自Adobe的ColdFusion 9 。 下载并安装免费的开发人员版本。

  • Flash Builder 4 beta 2 from Adobe Labs, which we’ll use to build our AIR app. We’ll be using the Flex 3.4 SDK, so you could in theory use Flex Builder 3 for most of what we’ll be doing, but Flash Builder 4 will simplify a few key tasks.

    Adobe Labs的Flash Builder 4 beta 2 ,我们将用它来构建AIR应用程序。 我们将使用Flex 3.4 SDK,因此理论上您可以将Flex Builder 3用于我们将要执行的大部分工作,但是Flash Builder 4将简化一些关键任务。

  • The sample code, which is available here. The archive includes both an .fxp project that you can import into Flash Builder, and the raw source files in case you want to look at them on their own.

    示例代码, 可在此处获得 。 该归档文件既包含可导入Flash Builder的.fxp项目,又包含原始源文件(以防您自己查看原始文件)。

Once you’re done reading the article, head over and test your new skills in our Article Quiz!

阅读完文章后,请转至我们的文章测验中测试您的新技能!

基础 (The Basics)

Before we start working through the example, let’s have a look at some basic CFaaS features and how we can make use of them. In ColdFusion 9, the following tags and their functionality are available as SOAP/WSDL-based web services:

在开始研究示例之前,让我们看一下一些基本的CFaaS功能以及如何使用它们。 在ColdFusion 9中,以下标记及其功能可作为基于SOAP / WSDL的Web服务使用:

  • <cfchart>

    <cfchart>

  • <cfdocument>

    <cfdocument>

  • <cfimage>

    <cfimage>

  • <cfmail>

    <cfmail>

  • <cfpop>

    <cfpop>

  • <cfpdf>

    <cfpdf>

The WDSL URLs for these services follow the format: http://<servername>:<port>/CFIDE/services/<servicename>.cfc?wsdl. So, if you installed ColdFusion 9 on your local machine using its built-in HTTP server, the WSDL URL to access the image service will be: http://localhost:8500/CFIDE/services/image.cfc?wsdl. All the examples and sample code will be using this format, so if you’re using a different server name or port, you’ll need to adjust the URLs accordingly.

这些服务的WDSL URL遵循以下格式: http://<servername>:<port>/CFIDE/services/<servicename>.cfc?wsdl 。 因此,如果您使用本地的内置HTTP服务器在本地计算机上安装了ColdFusion 9,则用于访问映像服务的WSDL URL将为: http://localhost:8500/CFIDE/services/image.cfc?wsdl 。 所有示例和示例代码都将使用这种格式,因此,如果您使用其他服务器名称或端口,则需要相应地调整URL。

The WSDL URL of a service essentially exposes the entire service API, and this can pose a significant security risk. Because of this, the CFaaS engine is disabled by default, so you (or your ColdFusion server administrator) will need to set up a user account for the CFaaS layer and provide that user with appropriate access to the individual services. You’ll also need to provide a list or range of IP addresses that are permitted to access exposed services. For the purpose of this exercise we’ll just be accessing the service from our local machine, so you’ll only need to add 127.0.0.1 to that list.

服务的WSDL URL本质上公开了整个服务API,这可能会带来重大的安全风险。 因此,默认情况下CFaaS引擎是禁用的,因此您(或ColdFusion服务器管理员)将需要为CFaaS层设置用户帐户,并为该用户提供对各个服务的适当访问权限。 您还需要提供允许访问公开服务的IP地址列表或范围。 出于此练习的目的,我们仅从本地计算机访问服务,因此您只需要在该列表中添加127.0.0.1

To add the user for our service, we’ll first log in to the ColdFusion server administration area, located at http://localhost:8500/CFIDE/administrator/index.cfm. The two screens we’ll need are both found in the Security section: User Manager and Allowed IP Addresses.

要为我们的服务添加用户,我们将首先登录位于http://localhost:8500/CFIDE/administrator/index.cfm的ColdFusion服务器管理区域。 我们需要的两个屏幕都位于“ 安全性”部分:“ 用户管理器”和“ 允许的IP地址” 。

Figure 1. ColdFusion Administrator menu

图1. ColdFusion管理员菜单

ColdFusion Administrator menu

First, in the User Manager screen, create a user, specifying a username and password. At the bottom of the screen, move Image Service from the list of prohibited services to the list of exposed services.

首先,在“ 用户管理器”屏幕中,创建一个用户,并指定用户名和密码。 在屏幕底部,将Image Service从禁止的服务列表移动到公开的服务列表。

Figure 2. User Manager

图2.用户管理器

User Manager

Nevermind the other sections of this form, you can leave them alone for the purposes of this application. Make sure to remember the username and password you set for your new user, as you’ll need them to permit your AIR app to access the image service.

别介意此表单的其他部分,出于本应用程序的目的,您可以不理会它们。 确保记住为新用户设置的用户名和密码,因为您将需要它们来允许AIR应用访问图像服务。

翻译自: https://www.sitepoint.com/image-manipulation-coldfusion-9-air/

coldfusion

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值