Testing the Kshare Web Service XML

Next, you will create a Visual Basic .NET Windows application that accesses the Kshare and Login Web services. You will use this application to test the Kshare and Login Web services.

Create an Application That Accesses the Kshare and Login Web Services

To create a Visual Basic .NET Windows application that accesses the Kshare Web service, which is secured using the Windows security options, perform the following steps:

  1. To the existing solution, add a Visual Basic .NET Windows application.
  2. Using the Add Web reference dialog box, add a reference to the Kshare Web service.
  3. Add a button to the default form, and in the Click event of the button, add the following code:
  4. We have already discussed how to supply login credentials from the client in the section titled "Securing Web Services by Using Windows Authentication Methods." Next, you will look at creating a client for a Web service that implements the custom authentication discussed in the section "Securing Web Services by Using a Custom Solution." To create a Visual Basic .NET Windows application that accesses the Kshare Web service, which uses the Login Web service, perform the following steps:

  5. Launch Visual Studio .NET and create a Visual Basic .NET Windows application.
  6. In the Add Web Reference dialog box, add a Web reference to the Kshare Web service and the Login Web service. The .NET Framework creates a proxy class as usual. A portion of the declaration for the proxy class is shown in the following code:
  7. Add a Button control to the form of the client application. Then add the code to call the LoginCheck() method of the Login Web service. The LoginCheck() method allows you to log in to the Web service.
  8. Add the code to store the returned session ID in a string variable. Next, use the session ID to call a Web method in the Service1 Web service. The code to do this is as follows:

This is the web service we are securing Declare and initialize an object of the Header1 type. Store the session ID and assign it to the Header1 variable that is declared in the Web service. In the code for the proxy, rename the variable to Header1Value.

Adding Code to the Button Control

Now add a Button control to the Visual Basic .NET Windows application that you created in the previous section. In the Click event handler for the Button control, add the following code:

Because your Web service is secured using Windows Basic authentication, you need to provide the login credentials, as shown in the previous code sample.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XML Topics