What should you do?

A Web service named Math uses Web Service Enhancements (WSE) 3.0 policy assertions that are defined in the policy configuration file to implement security.
The Web service authenticates access to the Web methods using the UsernameOverTransportAssertion policy assertion.
A client application must call a Web method on the Math Web service.
When the client application is executed, it throws an InvalidOperationException exception that displays the following text.

Unable to determine client token to use. Client token type requested was ‘Microsoft.Web.Services3.Security.Tokens.UsernameToken’.

The following code is used to invoke the Web method.

(Line numbers are included for reference only.)
01 Math ws = new Math();
02 ws.SetPolicy(“Secure”);
03 int result = ws.Add(3, 4);

You need to ensure that the Web methods can be invoked without causing the client application to throw the InvalidOperationException exception.

What should you do?

A Web service named Math uses Web Service Enhancements (WSE) 3.0 policy assertions that are defined in the policy configuration file to implement security.
The Web service authenticates access to the Web methods using the UsernameOverTransportAssertion policy assertion.
A client application must call a Web method on the Math Web service.
When the client application is executed, it throws an InvalidOperationException exception that displays the following text.

Unable to determine client token to use. Client token type requested was ‘Microsoft.Web.Services3.Security.Tokens.UsernameToken’.

The following code is used to invoke the Web method.

(Line numbers are included for reference only.)
01 Math ws = new Math();
02 ws.SetPolicy(“Secure”);
03 int result = ws.Add(3, 4);

You need to ensure that the Web methods can be invoked without causing the client application to throw the InvalidOperationException exception.

What should you do?

A.
Add the following code between lines 02 and 03.
ws.Credentials = System.Net.CredentialCache.DefaultCredentials

B.
Add the following code between lines 02 and 03.
ws.Credentials = new System.Net.NetworkCredentials(userId, password);

C.
Add the following code between lines 02 and 03.
ws.SetServiceCredential<UsernameToken>(new UsernameToken(userId, password));

D.
Add the following code between lines 02 and 03.
ws.SetClientCredential<UsernameToken>(new UsernameToken(userId, password));



Leave a Reply 0

Your email address will not be published. Required fields are marked *