ServiceReference Class
Registers a Web service for use in a Web page.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
The ServiceReference type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ServiceReference() | Initializes a new instance of the ServiceReference class. |
![]() | ServiceReference(String) | Initializes a new instance of the ServiceReference class with a specified path. |
| Name | Description | |
|---|---|---|
![]() | InlineScript | Gets or sets a value that indicates whether the proxy generation script is included in the page as an inline script block or is obtained by a separate request. |
![]() | Path | Gets or sets the path of the referenced Web service. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetProxyScript | Provides a proxy script from a derived ServiceReference object that can be overridden as a customization. |
![]() | GetProxyUrl | Provides a proxy URL from a derived ServiceReference object can be overridden as a customization. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the value of the Path property or the type name. (Overrides Object::ToString().) |
To call Web service methods from ECMAScript (JavaScript), you must include a service reference in the ASP.NET page and apply the ScriptServiceAttribute attribute to the Web service class definition. If you include a service reference to a Web service in the ScriptManager or ScriptManagerProxy control inside the ASP.NET page, JavaScript objects will be instantiated in the browser.
The proxy objects will be used to do the following:
Make asynchronous requests in JavaScript to Web service methods,
Initialize instances of proxies of server data types, in particular for use as input parameters for invoking Web methods.
Note |
|---|
The ServiceReference control can only be used for services in the same domain. |
You can define the Web service location declaratively by adding an <asp:ServiceReference> element to the <Services> element inside the <asp:ScriptManager> element on the page, and then setting its Path attribute, as shown in the following example.
<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference Path="~/WebServices/SimpleWebService.asmx" />
</Services>
</asp:ScriptManager>
You might use the InlineScript property to indicate whether the proxy generation script is included in the page as an inline script block or is obtained by a separate request.
You can also programmatically add a ServiceReference object through the ScriptManager::Services or ScriptManagerProxy::Services collection by using the Add method of the ServiceReferenceCollection class.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



Note