CatalogServiceAgent Constructor (String, String[], IPromptForCredentials)
Initializes a new instance of the CatalogServiceAgent class for communicating with a specific Web service using the provided type of Web service proxy object.
Namespace: Microsoft.CommerceServer.Catalog
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
Public Sub New ( _
url As String, _
supportedAuthMethods As String(), _
prompter As IPromptForCredentials _
)
'Usage
Dim url As String
Dim supportedAuthMethods As String()
Dim prompter As IPromptForCredentials
Dim instance As New CatalogServiceAgent(url, supportedAuthMethods, _
prompter)
public CatalogServiceAgent(
string url,
string[] supportedAuthMethods,
IPromptForCredentials prompter
)
public:
CatalogServiceAgent(
String^ url,
array<String^>^ supportedAuthMethods,
IPromptForCredentials^ prompter
)
public function CatalogServiceAgent(
url : String,
supportedAuthMethods : String[],
prompter : IPromptForCredentials
)
Parameters
- url
Type: System..::.String
The URL of the Web service this agent will run against.
- supportedAuthMethods
Type: array<System..::.String>[]()[]
A list of authorization modes which are allowed.
- prompter
Type: Microsoft.CommerceServer..::.IPromptForCredentials
An IPromptForCredentials instance which will handle prompting for credentials if required.
Remarks
The Catalog Agent serves to abstract data from the user interface. Additionally, it caches frequently changing data and batch-processes user interface queries.
Examples
This example shows how to initialize a ServiceAgent with a CredentialPrompter callback.
using System.Net;
using Microsoft.CommerceServer.Catalog;
using Microsoft.CommerceServer;
public ServiceAgent CreateCatalogAgent(string url)
{
CatalogServiceAgent mktgAgent = new CatalogServiceAgent(
url, ServiceAgent.DefaultAuthMethods, new MyCredentialPrompter
return mktgAgent;
}
public class MyCredentialPrompter :
{
public NetworkCredential PromptForCredentials(string url, string authType)
{
// Typically these values would be retrieved from a
// dialog box presented to a user prompting them to
// enter authentication credentials.
string username = "theUser";
string password = "pwd";
string domain = "domain";
NetworkCredential credentials = new NetworkCredential(
username, password, domain);
return credentials;
}
}
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.