Learn About MCSD Microsoft .NET Skills

  BackBy Certification Magazine —

1 | 2 | 3 | 4 | 5 |

These questions are based on Cert-70-554VB: MSCert: UPGRADE: MCSD Microsoft .NET Skills to MCPD Enterprise Application Developer Using the Microsoft .NET Framework: Part 2 - Section 1.

A Self Test Software Practice Test

Objective: Create and Access XML Web services.
Sub-objective: Create and configure an XML Web-service method.

Single answer, multiple-choice

You are an enterprise application developer at Verigon Corp. You are creating an XML Web service named ClaimService for an insurance organization. The Web service connects to multiple data sources, including a DB2 and SQL Server 2005 database to retrieve and process customer claim data. The ClaimService Web service is defined as follows:

Public Class ClaimService
  Inherits WebService
    <WebMethod()> _
    Public Function ProcessClaim(ByVal ClaimID As String) As Integer
        'Implementation code
    End Function
End Class

The ProcessClaim method must authenticate with each database using the network credentials of the client application. The client application requires all users to log in to the Windows domain before processing or accessing claim data. Which code should you use to invoke the ProcessClaim method?

A.    Dim proxy As New ClaimService
Dim nc As New System.Net.NetworkCredential("CurrentUser","Pa$$w0rd")
Dim cc As New System.Net.CredentialCache()
cc.Add(New Uri(proxy.Url), "Basic", nc)
proxy.Credentials = cc
proxy.ProcessClaim("1001")

B.    Dim proxy As New ClaimService
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials
proxy.ProcessClaim("1001")

C.    Dim proxy As New ClaimService
Dim cc As New System.Net.CredentialCache()
proxy.Credentials = cc.DefaultNetworkCredentials
proxy.ProcessClaim("1001")

D.    Dim proxy As New ClaimService
proxy.Credentials =
a.    System.Net.CredentialCache.DefaultNetworkCredentials
proxy.ProcessClaim("1001")

Answer:
D.    Dim proxy As New ClaimService
proxy.Credentials =
a.    System.Net.CredentialCache.DefaultNetworkCredentials
proxy.ProcessClaim("1001")

Tutorial:
You should use the following code to invoke the ProcessClaim method with the current client log-in credentials:

Dim proxy As New ClaimService
proxy.Credentials =
    System.Net.CredentialCache.DefaultNetworkCredentials
proxy.ProcessClaim("1001")

This code is correct because it sets the Credentials property of the Web proxy to the network credentials of the current security context and then calls the Web method. This code instantiates a ClaimService Web proxy and sets the Credentials property to the DefaultNetworkCredentials property of the CredentialCache class. When the ProcessClaim method is invoked the domain credentials will be sent to the ClaimService Web service for authentication with the required databases.

The CredentialCache class is used to store credentials for multiple resources. Whenever such a resource is requested, the credentials for the resource are retrieved from the CredentialCache class for authentication. This class has two properties:

•    DefaultCredentials: Retrieves the local system credentials of the current security context. The system credentials refer to the account(s) on the local machine.
•    DefaultNetworkCredentials: Retrieves the network credentials of the current security context. The network credentials refer to the local account(s) impersonated across the network or Windows domain.

You should not use the following code to invoke the ProcessClaim method with the current client log-in credentials:

Dim proxy As New ClaimService
Dim nc As New System.Net.NetworkCredential("CurrentUser","Pa$$w0rd")
Dim cc As New System.Net.CredentialCache()
cc.Add(New Uri(proxy.Url), "Basic", nc)
proxy.Credentials = cc
proxy.ProcessClaim("1001")

This code does not specify the current network credentials of the client application because it codes new network credentials. It instantiates a new NetworkCredential object with the username and password as "CurrentUser" and "Pa$$w0rd", respectively. The code then instantiates a CredentialCache object and adds the NetworkCredential object. The Add method takes three parameters: the Uniform Resource Identifier (URI) of the Web service, the authentication protocol (Basic, Digest or Integrated) as a string and NetworkCredential instance.

Then the Credentials property of the Web proxy is set to CredentialCache object, and the ProcessClaim method is invoked. This will send new network credentials to the ClaimService Web service. In this scenario, you should use the DefaultNetworkCredentials property to specify the network credentials of the current client log-in.

You should not use the code that specifies the DefaultCredentials property because this does not represent the network credentials for the current client log-in. The DefaultCredentials property indicates the system credentials on the local machine, not the credentials across the network. In this scenario, you should use the DefaultNetworkCredentials property to specify the network credentials of the current client log-in.

You should not use the code that instantiates a CredentialCache object and specifies the DefaultNetworkCredentials property because this property is a class member. Thus, you do not need to and should not instantiate a CredentialCache object to specify the DefaultNetworkCredentials property.

References:
MSDN2 Library, Search, ".NET Development," ".Net Framework SDK," "Class Library Reference," "System.Net," "CredentialCache Class."

MSDN2 Library, Search, ".NET Development," ".Net Framework SDK," "Class Library Reference," "System.Net," "NetworkCredential Class."

MSDN2 Library, Search, ".NET Development," ".Net Framework SDK," "Class Library Reference," "System.Net," "CredentialCache Class," "DefaultNetworkCredentials Property."


Objective: Configure and customize a Web-service application.
Sub-objective: Configure SOAP messages.

Single answer, multiple-choice

As an enterprise application developer, you have created the following Web service for Verigon Corp. contractors:

<WebServiceBinding(Name:="PartnerBinding", _
Namespace:="http://www.GeoTrek.com/Verigon")> _
<WebServiceBinding(Name:="ExternalBinding", _
Namespace:="http://www.Verigon.com/External", _
Location:="http://www.Verigon.com/External/ContractSevice.xsd")> _
<WebService(Namespace:="http://www.Verigon.com/internal")> _
Public Class ContractService
    Inherits System.Web.Services.WebService

    Public Sub MakePayment(ByVal amount As Double)
        'implementation
    End Sub

    Public Sub AdjustRate(ByVal amount As Double)
        'implementation
    End Sub
End Class

The MakePayment method should be available to external contractors while the AdjustRate method must remain internal to Verigon. What should you do?

1 | 2 | 3 | 4 | 5 |
Viewed 8778 times.
SPONSORED LINKS