What should you do?

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. The development and deployment of Extensible Markup Language (XML) Web Services forms part of your responsibilities at Domain.com.
The following exhibit illustrates a class definition:

public class MarketService
{
internal string ObtainMarket(string mobilePhoneNumber)
{
return String.Empty;
}
}

You received instruction to modify this class so that it becomes a Web service, a Web service that will allow internal applications to invoke ObtainMarket as a Web method. You need to ensure that the Web method does not make use of session state and that it must make use of the default namespace.

What should you do?

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. The development and deployment of Extensible Markup Language (XML) Web Services forms part of your responsibilities at Domain.com.
The following exhibit illustrates a class definition:

public class MarketService
{
internal string ObtainMarket(string mobilePhoneNumber)
{
return String.Empty;
}
}

You received instruction to modify this class so that it becomes a Web service, a Web service that will allow internal applications to invoke ObtainMarket as a Web method. You need to ensure that the Web method does not make use of session state and that it must make use of the default namespace.

What should you do?

A.
Change the access modifier for the ObtainMarket method to Public.
Then apply the WebService attribute to the MarketService class.

B.
Change the access modifier for the ObtainMarket method to Protected.
Then apply the WebMethod attribute to the ObtainMarket method.

C.
Change the access modifier for the ObtainMarket method to Public.
Then apply the WebMethod attribute to the ObtainMarket method.

D.
Derive the MarketService class from SoapHttpClientProtocol.
Then apply the WebMethod attribute to the ObtainMarket method.

E.
Derive the MarketService class from WebService.
Then apply the WebMethod attribute to the ObtainMarket method.

Explanation:
Only public methods can be exposed as Web methods. Thus you need to change the access modifiers to public. And you should also apply the WebMethod attribute to the ObtainMarket method as this attribute will indicate that the public method should be exposed as Web methods.
Incorrect answers:
A: The WebService attribute will allow you to specify the namespace and description for the Web service. This is not required to invoke Web methods. (In cases where no namespace has been specified, use will be made of the default namespace.)
B: Since only Public methods can be exposed as Web methods, you should not change the access modifier to Protected.
D: The SoapHttpClientProtocol base class allows for Web service clients to make SOAP calls to Web methods. This is not what is required.
E: The WebService base class is an optional class as it provides direct access to session and application instances for session state. It is mentioned in this question that the Web methods does not make use of session state.



Leave a Reply 0

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