Invoke a Web Service

In order to use a Web Service from a .NET application, you need to add a Web reference to your project for each one you want to use. Web References are generated from the service Web Services Description Language (WSDL) when providing its URL. For example:


Once a Web reference has been added to your project, you can write code to invoke the web methods contained in the service. The following simple code example demonstrates this:

// initialize service
ManagedEmail2007.Service service = new ManagedEmail2007.Service();
service.Credentials = new NetworkCredential("Fabrikam\\Administrator", "Pass1word");
// populate message data
ManagedEmail2007.CreateMailboxRequestData data = new ManagedEmail2007.CreateMailboxRequestData();
data.path = "LDAP://,OU=AlpineSkiHouse,OU=ConsolidatedMessenger,OU=Hosting,DC=Fabrikam,DC=Com";
data.preferredDomainController = "AD01.Fabrikam.Com";
data.alias = "JohnChen";
data.prohibitSendQuota = 2048;
data.prohibitSendQuotaSpecified = true;
// send request
bool sendCredentials = true;
ManagedEmail2007.CreateMailboxRequest request = new ManagedEmail2007.CreateMailboxRequest();
request.Data = data;
ManagedEmail2007.CreateMailboxResponse response = new ManagedEmail2007.CreateMailboxResponse();
response = service.CreateMailbox(request, sendCredentials);