PrepAway - Latest Free Exam Questions & Answers

What should you do?

When you execute a client application, the following exception is
thrown.

EncryptedKeyToken is expected but not present in the security header of the incoming message.

You discover that the exception is thrown when the client application invokes a Web service named Math with the following code.

(Line numbers are included for reference only.)
01 try
02 {
03 MathWse ws = new MathWse ();
04 int result = ws.Add(1, 2);
05 }
06 catch (Exception ex)
07 {
08 MessageBox.Show(ex.Message);
09 }

The client application and Web service have the same Web Services Enhancements (WSE) 3.0 policy.
The policy configuration file contains the following policy section.

<policy name=”Secure”>
<anonymousForCertificateSecurity establishSecurityContext=”false” renewExpiredSecurityContext=”true” requireSignatureConfirmation=”false” messageProtectionOrder=”SignBeforeEncrypt” requireDerivedKeys=”true” ttlInSeconds=”300″>
<!– XML defining the serviceToken and protection –>
</anonymousForCertificateSecurity>
</policy>

You need to ensure that the client application can communicate with the Web service.

What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Add the following code between lines 03 and 04.
ws.SetPolicy(“Secure”);

B.
Replace line 03 with the following code.
Math ws = new Math();

C.
Add the following code between lines 03 and 04.
ws.UseDefaultCredentials = true;

D.
Add the following code between lines 03 and 04.
UsernameToken u = new UsernameToken(“userid”, “password”);
EncryptedKeyToken et = new EncryptedKeyToken(u);
ws.SetClientCredential(et);

E.
Add the following code between lines 03 and 04.
ws.SetPolicy(“anonymousForCertificateSecurity”)


Leave a Reply