CHAPTER 8
284
Using Server-side Proxies
HTTPService and WebService were covered in enough detail in the last chapter. There we emphasized
that these services promote loose coupling and can be used to access data in a Flash Player independent
of a server infrastructure. The only mandatory requirement was that the external host provide a cross-
domain security policy definition. This requirement was never a concern if the host already had a
crossdomain.xml file allowing access or if it was possible to request the host maintainers to put one in
place. However, in the vast expanse of the World Wide Web, it’s not always possible for such a good
arrangement to be in place. In situations where we are unable to access data from an external host due to
security restrictions, it’s viable to fetch it via data services. In this role, data services provide the proxy
service for HTTPService and WebService components.
The server-side configurations for proxy settings are made in the proxy-config.xml file. This file is included by
reference in services-config.xml. The HTTPService sends HTTP requests down to the proxy, and the
WebService sends SOAP web service calls down to the proxy. In either case, we need a service adapter to take
these requests and translate them into the final call. For example, an HTTP request needs to end up with a URL
invocation. You saw messaging service adapters in the context of messaging. The service adapters for HTTP
and web service proxies implement a similar set of classes to create a service adapter. Default HTTP proxy and
SOAP web service proxy adapters are available in BlazeDS.
For HTTPService, you can define a URL for the proxy setting or set up a set of dynamic URL(s) that are
resolved to the appropriate URL based on the URL value set in the client-side HTTP call. For web
services, you define either the WSDL URL or the SOAP endpoint URL pattern. These URL configurations
are done with destination configuration. It’s also possible, especially with HTTPService, to define a default
destination and have a set of dynamic URLs with it. Then every HTTPService call via data services is
routed through this destination to the HTTP proxy adapter.
The proxy service itself can be configured with a number of properties. We present a sample of the
configuration file available in the distribution and in the documentation and explain the properties in
context. Here is the sample configuration:
<service
id="proxy-service"
class="flex.messaging.services.HTTPProxyService">
<properties>
<connection-manager>
<max-total-connections>100</max-total-connections>
<default-max-connections-per-host>
2</default-max-connections-per-host>
</connection-manager>
<!-- Allow self-signed certificates;
should not be used in production -->
<allow-lax-ssl>true</allow-lax-ssl>
<external-proxy>
<server>10.10.10.10</server>
<port>3128</port>
<nt-domain>mycompany</nt-domain>
<username>flex</username>
<password>flex</password>
</external-proxy>
</properties>
</service>

Get AdvancED Flex 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.