Note: The NetServices class and its methods are deprecated in Flash Remoting for Flash MX 2004 in favor of the Service class. For more information, see mx.remoting.Service.
Note: You cannot use the PendingCall or RelayResponder classes with the NetServices class to handle results or fault conditions that are returned from service functions. For information on how to handle results and fault conditions with the NetServices class, see Using NetServices and Connection Classes.
The NetServices class is for Flash Remoting use only.
The NetServices class is a collection of methods that helps you create and use connections to services using Flash Remoting.
You can import the NetServices class using the following import statement:
import mx.remoting.NetServices;
See Also
mx.remoting.Service
| Methods | |
static | createGatewayConnection(
url:
String, log:
Log)
: ConnectionEstablishes the required connection information for communication to the gateway. |
static | getConnection(
uri:
String)
: ConnectionReturns a Connection object for the specified URL from a pool of shared connections. |
static | getHostUrl(
)
: StringReturns a string containing the hostname and port of the URL that contains the current SWF file, without a trailing /. |
static | getHttpUrl(
url:
String)
: StringConverts a relative URL to a full URL by prepending the hostname, if the provided URL is a non-HTTP URL. |
static | setDefaultGatewayUrl(
url:
String)
: VoidSets the default URL that Flash Remoting uses when it executes the createGatewayConnection() method and you do not otherwise specify the gateway URL. |
static | setGatewayUrl(
url:
String)
: VoidSpecifies the URL to be used for a Flash Remoting gateway connection. |
| Properties | |
static | version:
String Component version. |
| Method Detail |
static
createGatewayConnection(
url:
String, log:
Log)
: Connection
Parameters
url:
String - containins the Flash Remoting gateway URL.
log:
Log - [optional] logger used to capture messages generated during this method invocation Note: this parameter is for internal use only
Returns
A new Connection object for the connection to the gateway URL, specified in one of the following ways:
setDefaultGatewayUrl() method is used if it is invoked with a valid URL prior to this method. setGatewayURL() method if it is invoked with a valid URL prior to the createGatewayConnection() method import mx.remoting.NetServices;
import mx.remoting.NetServiceProxy;
import mx.remoting.Connection;
// var conn:Connection = NetServices.createGatewayConnection(
"http://localhost:8300/flashservices/" );
var custService:NetServiceProxy = conn.getService( "customerData" );
See Also
mx.remoting.Connection.connect
mx.remoting.Service.Service
static
getConnection(
uri:
String)
: Connection
null. Connections are added to the pool by calling the createGatewayConnection() method.
Parameters
uri:
String - A string that specifies the location of the gateway.
Returns
A connection object with the specified URL or a null value if no connection is found. The connection is retrieved from a shared pool of connections.
getConnection:
import mx.remoting.NetServices;
import mx.remoting.NetServiceProxy;
import mx.remoting.Connection;
// we want to share this connection to batch requests to the server
var conn:Connection = NetServices.getConnection("http://localhost:8300/
flashservices/");
// if we don't have one yet, let's create it!
if( conn == null )
conn = NetServices.createGatewayConnection("http://localhost:8300/
flashservices/");
var custService:NetServiceProxy = conn.getService( "customerData" );
// ...
See Also
mx.remoting.Service.Service
mx.remoting.Connection.connect
mx.remoting.NetServices.setDefaultGatewayUrl
mx.remoting.NetServices.setGatewayUrl
static
getHostUrl(
)
: String
/. Returns a value of null if the URL does not begin with http:. For example, if the SWF file URL is http:, the function returns http:.
Returns
A string that specifies the hostname and port.
NetServices.getHostUrl() method extracts from a URL like "http://my.foo.com:1234/some/thing/my.swf" a hostname and port like "http//my.foo.com:1234" and appends the string "/images/customer.jpg":
var host:String = NetServices.getHostUrl();
loader.source = host + "/images/customer.jpg";
See Also
mx.remoting.NetServices.getConnection
mx.remoting.NetServices.getHttpUrl
mx.remoting.NetServices.setGatewayUrl
static
getHttpUrl(
url:
String)
: String
Parameters
url:
String - A string that specifies the URL to be converted.
Returns
A string that contains the full URL.
"/images/cust") to obtain a full URL such as "http://my.foo.com:1234/images/cust":
loader.source = NetServices.getHttpUrl("/images/cust");
See Also
mx.remoting.NetServices.getConnection
mx.remoting.NetServices.getHostUrl
mx.remoting.NetServices.setGatewayUrl
static
setDefaultGatewayUrl(
url:
String)
: Void
createGatewayConnection() method and you do not otherwise specify the gateway URL.
Parameters
url:
String - The default URL to be set.
setDefaultGatewayUrl() method to establish the gateway that will be used by the createGatewayConnection() method:
import mx.remoting.NetServices;
import mx.remoting.NetServiceProxy;
import mx.remoting.Connection;
// set the default gateway
NetServices.setDefaultGatewayUrl("http://localhost:8300/flashservices/" );
var conn:Connection = NetServices.createGatewayConnection(); // connect
var custService:NetServiceProxy = conn.getService( "customerData" );
See Also
mx.remoting.NetServices.createGatewayConnection
mx.remoting.NetServices.getHostUrl
mx.remoting.NetServices.getHttpUrl
mx.remoting.NetServices.setGatewayUrl
static
setGatewayUrl(
url:
String)
: Void
Parameters
url:
String - A string that specifies a URL that is to be set as the gateway.
setGatewayUrl() method to set the URL that is used by the createGatewayConnection() method:
import mx.remoting.NetServices;
import mx.remoting.NetServiceProxy;
import mx.remoting.Connection;
// set the gateway Url
NetServices.setGatewayUrl("http://localhost:8300/flashservices/" );
var conn:Connection = NetServices.createGatewayConnection(); // connect
// create proxy for customerData service
var custService:NetServiceProxy = conn.getService( "customerData" );
See Also
mx.remoting.NetServices.createGatewayConnection
mx.remoting.NetServices.getConnection
mx.remoting.NetServices.getHostUrl
mx.remoting.NetServices.getHttpUrl
mx.remoting.NetServices.setDefaultGatewayUrl
| Property Detail |
static
version:
String
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx2004/actionscript_api_reference/mx/remoting/NetServices.html
Comments
No screen name said on Jan 26, 2005 at 2:41 PM :