Creating a .NET web service client
- Create a basic web service named SimpleWebService.
Install Microsoft .NET Runtime and Visual Studio .NET 7.0 from http://www.microsoft.com/visualstudio/11/en-us/downloads.
- Open Visual Studio .NET 7.0.
- Select File > New > Project.
- From the set of available project types, select Visual C# Projects.
- Select Console Application from Templates.
- In the Name field, enter WSClient.
- In the Location field, enter the directory name in which you want to store the project files. (for example, C:\temp).
- Click OK.
- Select View > Solution Explorer.
- In Solution Explorer, right-click WSClient and select Add Web Reference.
- In the Address bar, enter the URL for WSDL (for example, http://<midtierServer>/arsys/WSDL/<arServer>/SimpleWebService, as created in the Creating-a-basic-web-service procedure).
For information about WSDL, see http://www.w3.org/TR/wsdl. - Enter the user name and password, and click Login (this is needed only if public access is not provided to the web service that you created).
- Click Add Reference.
- Select Project > Show All Files.
- In Solution Explorer, under Web References, right-click SimpleWebService.cs and select View Code.
SimpleWebService.cs is the proxy class generated for making requests to your web service. - Click the Class1.cs tab.
- After the using System statement, enter the following statement on a separate line:
using WSClient.<midtierServer>; Enter the following code in the Main method (after the //TODO... statement):
// create a proxy object to make web service requests
SimpleWebService proxy = new SimpleWebService();
// set up authentication info
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.userName = "Demo"; // give a valid AR user name
authInfo.password = ""; // give a valid password
proxy.AuthenticationInfoValue = authInfo;
// declare variables
String Assigned_To;
String Short_Description;
StatusType Status;
String Submitter;
String Request_ID;
// supply values for creating an entry using OpCreate
Assigned_To = "Frank";
Short_Description = "Testing web service";
Status = StatusType.New;
Submitter = "Joe";
// make web service request to create an entry and make changes to this code as per the operation names defined in your web service
Request_ID = proxy.OpCreate(Assigned_To, Short_Description, Status, Submitter);
Console.WriteLine("Successfully created a request with id: " + Request_ID);
// declare additional variables for get operation
DateTime Create_Date;
String Last_Modified_By;
DateTime Modified_Date;
String Status_History;
// make web service request to get the entry that was created above
Assigned_To = proxy.OpGet(ref Request_ID, out Create_Date, out Last_Modified_By, out Modified_Date,
out Short_Description, out Status, out Status_History, out Submitter);
Console.WriteLine();
Console.WriteLine("Following values have been returned by OpGet");
Console.WriteLine();
Console.WriteLine("Request_ID : " + Request_ID);
Console.WriteLine("Create_Date : " + Create_Date);
Console.WriteLine("Last_Modified_By : " + Last_Modified_By);
Console.WriteLine("Modified_Date : " + Modified_Date);
Console.WriteLine("Short_Description : " + Short_Description);
Console.WriteLine("Status : " + Status);
Console.WriteLine("Status_History : " + Status_History);
Console.WriteLine("Submitter : " + Submitter);
Console.WriteLine("Assigned_To : " + Assigned_To);- Select Build > Rebuild All.
- Change directory to C:\temp\WSClient\bin\Debug.
- Enter WSClient.exe at the command prompt to run the client.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*