Вы находитесь на странице: 1из 8

MCTS:.NET4.0:ServiceCommunicationApplications EXAM:TS:70513 NewQuestions Question:1 YouarecreatingaWindowsCommunicationFoundation(WCF)servicethatimplementsoperations inaRESTfulmannerYouneedtoaddadeleteoperationYouimplementthedeletemethodas follows.stringoidDelectates(stringid);Youneedtoconfigi.reWCFtocithismethodwhentheclient callstheservicewiththeHTTPDRETEoperaonWhatshouldyoudo? A.AddtheWeblnvoke(UriTemplate="/Items/(idy,Method=DELETE")attributetotheoperation B.AddtheHttpDeletetributetotheoperation C.ReplacethestnngparameterwithaRemovedActivityActionparameter D.ReplacetheretumntypewithRemovedActivityktion. Answer:A Question:2 AWindowsCommunicationFoundation(WCF)serviceusesthefollowingservicecontract.

act. [ServceContract] publicinterfaceIService { [OperationContract] stringOperation1(stnngs); } YouneedtoensurethattheoperationcontractOperationirespondstoHTTPPOSTrequests.Which codesegmentshouldyouuse? A.[OperationContract|[Weblnvoke(MethodPOST)]stringOperation(strings); B.[OperationContract|[WebGet(UriTemplate=POST)]stringOperation1(strings); C.[OperationContract(ReplyActionzPOST)JstringOperationi(strings); D.[OperationContract(ActionWPOST)1stringOperation(strings); Answer:A Question:3 AWindowsCommunicationFoundation(WCF)serviceimplementsthefollowingcontract. [ServiceContract| publicinterfaceIHelloService { [OperationContract] [VVebGet(UriTemplate=hello?namee{name})] stringSayHello(stringname); } Theimplementationisasfollows. PublicclassHelloServicee:IHelloService { publicstringSayHello(stringname)

{ returnHello.+name; } } Thesenviceisselfhosted,andthehostingcodeisasfollows. WebServiceHostsvcHost=CreateHoseO; svcHost.OpenO; Console.ReadLineO; SrvHost.CloseO; YouneedtoimplementCreateHostsothatthesenvicehasasingleendpointhostedat http://localhost:8OO0/HelloService.Whichcodesegmentshouldyouuse? A.WebServiceHostsvcHostnewWebServiceHost(typeof(HelloService)); svcHost.AddServiceEndpoint(typeof(lHelloService),newWebHttpBinding(WebHttpSecurityMode None),http://localhost:8000/HelloService); returnsvcHost; B.UrbaseAddress=newUrithttp:I/localhost:800O1");r WebServiceHostsvcHostnewWebServiceHost(typeof(HelloService),baseAddress); svcHostAddServiceEndpoint(typeof(lHelloService),newWebHttpBinding(WebHttpSecurityMode. None),HelloService); returnsvcHost; C.WebServiceHostsvcHost=newWebServiceHost(newHelloServiceO); svcHostAddServiceEndpoint(typeof(lHelloService),newWebHttpBinding(WebHttpSecurityMode. None),http://Iocalhost:8000/HelloService); retumnsvcHost D.UrbaseAddressnewUri(http//Iocalhost8000/"); WebServiceHostsvcHost=newWebServiceHost(newHelloService0,baseAddress),svc Host.AddServiceEndpoint(typeof(IHelloService),newWebHttpBinding(WebHttpSecurityMode None),"HelloService"); retumnsvcHost; Answer:A Question:4 YouareconsumingaWindowsCommunicationFoundation(WCF)service.Theserviceinterfaceis definedasollows. [DataContract(Namespace publicclassItem { [ServiceContract(Namespace=)] publicinterfaceCatalog { [OperationContract] [Vveblnvoke(Method=POST,UriTemplate=Iltem)] ltemUpdateltem(ltemitem);}

TheclientapplicationreceivesaWebResponsenamedresponsewiththeresponsefromtheservice. Youneedtodeserializethisresponseintoastronglytypedobjectrepresentingthereturnvalueof themethod.Whichcodesegmentshouldyouuse? A.DataContractSerializers=newDataContractSerializer(typeof(Item)); Itemitem=s.ReadObject(response.GetResponseStream0)asItem; B.BinaryFormatterf=newBinaryFormatter0;o Itemitem=f.DeseriaIize(response.GetResponseStream0)asItem; C.XmlDictionaryReaderr=JsonReaderWriterFactory.CreateJsonReader(response. GetResponseStream0,t XmlDictionaryReaderQuotas.Max);DataContractSerializers=new DataContractSerializer(typeof(ltem)); Ltemitems.ReadObject(r)asttem; D.DataContractJsonSerializers=newDataContractJsonSerializer(typeof(Item)); Itemttem=s.ReadObject(response.GetResponseStream0)asttem; Answer:A Question:5 AclassnamedTestServiceimplementsthefollowinginterface. [ServiceContract] publicinterfacelTestService { [OperationContract] DateTimeGetServiceTimeo; } TestServiceishostedinanASP.NETapplication.Youneedtomodifytheapplicationtoallowthe GetServiceTimemethodtoreturnthedataformattedasJSON.Itmustdothisonlywhentherequest URLendsin/ServiceTimeWhatshouldyoudo? A.AddthisattributetotheGetServiceTimemethod.[Weblnvoke(MethodePOSl)]Intheweb.config file,addthiselementtosystem.serviceModel/behaviors/endpointBehaviors. <behaviornamee"Json>c<enableWebScriptI></behavior>Intheweb.configfile,configureTest Serviceinthesystem.serviceModel/servicescollectionasfollows <servicenamezTestService><endpointaddresse"/ServiceTimecontractsTestServicer behaviorConfigurationzUsonbindingzwebHttpBindingI></service> B.AddthisattributetotheGetServiceTimemethod.[Weblnvoke(Method=GET,UriTemplate "/ServiceTime,ResponseFormat=WebMessageFormat.Json)]Intheweb.configfile,configureTest Serviceinthesystem.serviceModel/servicescollectionasfollows.<servicenamezTestService"> <endpointaddress="/ServiceTimecontract=TestServicebindingewebHttpBinding!s?</service> C.AddthisattributetotheGetServiceTimemethod[VVebGet(ResponseFormat= WebMessageFormatJson,UriTemplatee"/ServiceTime)]Createanewsvcfilenamed Jsonversion.svcwiththefollowingcontent.<%@ServiceHostServicee"TestService FactoryeSystemServiceModeLActivationWebServiceHostFactory"%> D.AddthisattributetotheGetServiceTimemethod.[WebGet(UriTemplate={Uson)/ServiceTime)] Createanew.svcfilenamedJsonversionsvcwiththefollowingcontent<%aServiceHost ServiceeTestServiceeFactory=SystemServiceModel.ActivationWebServiceHostFactory"%>

Answer:C Question:6 YouareconsumingaWindowsCommunicationFoundation(WCF)serviceinanASP.NETWeb application.Theserviceinterfaceisdefinedasfollows. [ServiceContract] publicinterfacelCatalog { [OperationContract] [WebGet(UriTemplate=/Catalog/ltems/{id},ResponseFormat=WebMessageFormatJson)] stringRetrieveltemDescription(intid); } Thesenviceishostedat/CatalogsvcYouneedtocalltheserviceusingjQuerytoretrievethe descriptionofanitemasindicatedbyavariablenameditemldWhichcodesegmentshouldyou use? A.$get(StringformatC/Catalogsvc/Catalog/ttems/ide{O},itemld)null,function(data){}, javascript); B.$get(StringJormat(/Catalogsvc/Catalog/ttems/{O},itemld),null,function(data){...}UjsnII);i C.S.get(String.format(/Catalogsvc/Catalogfltems/{O},itemld),null,function(data){},xml); D.S.get(String.format(/Catalogsvc/Catalog!ltems/ide{O},itemld),null,function(data){},json); Answer:B Question:7 YouarecreatingaWindowsCommunicationFoundation(WCF)servicethatrespondsusingplainold xML(POX).Youhavethefollowingrequirements Youmustenablethe/catalog.svcfitemsoperationtorespondusingthePOX,JSON,orATOM formats.YoualsomustensurethatthesameURLisusedregardlessoftheresulttype. YoumustdeterminetheresponseformatbyusingtheAcceptsHTTPheader. Whatshouldyoudo? A.ImplementtheIChannellnitializerinterfaceintheserviceclass B.ImplementtheSystemRuntime.Serialization.IFormatterConverterinterfaceintheserviceclass. C.SettheBodyStyleparameteroftheWebGetattributeontheoperationto WebMessageBodyStyleWrappedResponse. D.SettheretumtypeoftheoperationtoSystemServiceModelChannelsMessage.Usethecurrent WebOperationContextmethodstoreturnthedataintherequiredformat Answer:D Question:8 AnASPNETapplicationhostsaRESTfulWindowsCommunicationFoundation(WCF)serviceat /ServiceslContoso.svc.TheserviceprovidesaJavaScnptresourcetoclients.Youhaveanexplicit referencetotheJavaScriptinyourpagemarkupasfollows. <scripttypeetext/javaScriptsrcsIServices/Contoso.svc/jsI>

YouneedtoretrievethedebugversionoftheserviceJavaScnpt.Whatshouldyoudo? A.Inthe<%@ServiceHost%>headerfor/ServiceslContoso.svc,settheDebugattributetotrue. B.Inthe<%@Page%sheader,settheDebugattributetotrue. C.Inthescripttag,addadebugattributeandsetitsvaluetotrue. D.Inthescripttag,appenddebugtothesrcattribute Answer:D Question:9 YouarecreatinganASPNETwebapplicationthathostsseveralWindowsCommunication Foundation(WCF)servicesTheserviceshaveASP.NETCompatibilityModeenabled.Users authenticatewiththeWebapplicationbyusingacookiebasedASRNETFormsAuthentication model.YouaddaservicetilenamedAuthentication.Svcthatcontainsthefollowingcodesegment <%@SenviceHostServicee"SystemWebApplicationServicesAuthenticationService Factory="System.Web.ApplicationServices.AppicationServicesHostFactory%> YouneedtoensurethatuserscanaccesstheWCFserviceswithouthavingtoreauthenticate.Which twoconfigurationsettingsshouldyouadd?(Eachispartofacompletesolution.Choosetwo.) A.Inthesystemweb.Extensionsscripting/webServices!authenticationServiceelement,setthe enabledattributetotrue. B.Inthesystemweb.Extensionsscripting/webServices/profileServiceelement,settheenabled attributetotrue. C.AddaserviceendpointwithbasicHttpBindingforthecontractSystem.WebApplicationServices. AuthenticationService. D.AddacustomservicebehaviornamedAuthenticationServiceTypeBehaviorswithaservice AuthenticationManagerelementthathasserviceAuthenticationManagerTypesettoSystemWeb Security.SQLMembershipProvider Answer:A,C Question:10 AWindowsCommunicationFoundation(WCF)clientapplicationisconsuminganRSSsyndication feedfromablog.YouhaveaSyndicaionFeedvariablenamedfeed.Theapplicationiteratesthrough theitemsasfollows.(Linenumbersareincludedforreferenceonly.) 01foreach(Syndicationltemiteminfeed.ltems) 02{ 03} YouneedtodisplaythecontenttypeandbodyofeverysyndicationitemtotheconsoleWhichtwo linesofcodeshouldouinsertbetweenlines02and03? A.ConsoleWriteLine(tem.Content.Type);ConsoleWriteLine(((TextSyndicationContent)tem. Content).Text); B.Console.WriteLine(tem.Content.GetType0);Console.WriteLine(((TextSyndicationContent)tem. Content).Text); C.Console.WriteLine(tem.Content.Type),Console.WriteLine(tem.Content.ToString0);) D.Console.WriteLine(tem.Content.GetType0);Console.WriteLine(tem.Content.ToString0);)

Answer:A Question:11 YouhaveanexistingWindowsCommunicationFoundation(WCF)service.Youneedtoensurethat otherservicesarenotifiedwhentheserviceisstarted.Whatshouldyoudo? A.Addthefollowingstandardendpointtotheservice<endpoint name=udpAnnouncementEndpoint kind=udpDiscoveryEndpoint"I> B.Addthefollowingstandardendpointtotheservice <endpointnamezudpDiscoveryEndpoint kindeudpAnnouncementEndpoint"I> C.Addaservicebehaviorwiththefollowingelement. <serviceDiscovery> <announcementEndpointss <endpointkindeudpDiscoveryEndpoint"Is </announcementEndpointss </serviceDiscovery> D.Addaservicebehaviorwiththefollowingelement. <serviceDiscovery> <announcementEndpointss <endpointkind=udpAnnouncementEndpoinV"1s </announcementEndpoints> </serviceDiscovery> Answer:D Question:12 YouareimplementingaWindowsCommunicationFoundation(WCF)clientapplicationthat consumestheICatalogandlCatalog2serviceinterfacesYouneedtoensurethattheclientdiscovers servicesimplementingtheseinterfacesTheservicesmayalreadybeonlineormaycomeonline withina30secondtimelimitHowshouldyouuseWCFDiscoverytoaccomplishthis? A.CreateoneFindCriteriaobjectforeachinterfaceandsettheDurationofeachFindCritenato30 secondsCalltheFindAsyncmethodoftheDiscoveryChentclasstwice,onetimeforeachofthe FindCriteriaobjects,tosearchfortheservices. B.CreateoneFindCriteriaobyectforeachinterfaceandsettheDurationofeachFindCntenatotwo seconds.CreatealoopthatcallstheFindmethodoftheDiscoveryClientclasstosearchforthe services.Withineachloopiteration,calltheFindmethodoftheDiscoveryClientclassonceforeach oftheFindCriteriaobjectsRuntheloopuntilasevviceisfoundor30secondspass. C.CreateasingleFindCritenaobjectandaddbothinterfacestoitsContractTypeNamescollection. Setthecnteria'sDurationtotwoseconds.CreatealoopthatcallstheFindmethodofthe DiscoveryClientclasstosearchfortheservices.Withineachloopiteration,calltheFindmethodof theDiscoveryClientclasstosearchfortheservicesRuntheloopuntilasevviceisfoundor30 secondspass. D.CreateasingleFindCriteraobyectandaddbothinterfacestotheContractTypeNamescollection. SettheDurationto30secondsandusetheFindAsyncmethodoftheDiscoveryClientclasstosearch fortheservices. Answer:B

Question:13 YouaredevelopingawindowsCommunicationFoundation(WCF)servicethatwillbehostedin MicrosoftIntemnetInformationServices(IIS)7.0.TheservicemustbehostedinanlIsapplication namedInfo.YouneedtoenablethissenvicetobehostedinllSbychangingtheweb.configfile WhichXMLsegmentshouldyouaddtotheweb.conflgfile? A.<serviceHostingEnvironment><senviceActivations><addrelativeAddress="lnfosvcservicesYnfo I></serviceActivations><IserviceHostingEnvironment> B.<serviceHostingEnvironment><serviceActivations><addrelativeAddressz"lnfoservicezSinfo.svc I></serviceActivations></serviceHostingEnvironment> C.<serviceHostingEnvironment><transportConfigurationTypes><addnameelnfo transportConfigurationTypelnfo.svc"r><ItransportConfigurationTypes> <lserviceHostingEnvironment> D.<serviceHostingEnvironment><transportConfigurationTypes><addname=wlnfosvc" transportConfigurationTypeeFileNotRequired"I></transportConhgurationTypes> iserviceHostingEnvironment> Answer:A Question:14 AWindowsCommunicationFoundation(WCF)servicesendsnotificationswhentheserviceisstarted andstopped.Youneedtoimplementaclientthatlogsthesenotifications.Whichclassshouldyou use? A.AnnouncementService B.AnnouncementClient C.DiscoveryClient D.HttpListener Answer:A Question:15 AWindowsCommunicationFoundation(WCF)serviceimplementsacontractwithonewayand requestreplyoperations.TheserviceisexposedoveraTCPtransport.Clientsusearouterto communicatewiththeservice.Therouterisimplementedasfollows.(Linenumbersareincludedfor referenceonly.) 01ServiceHosthost=newServiceHost(typeof(RoutingService)); 02hostAddServiceEndpoint( 03typeof(lSimplexDatagramRouter), 04newNetTcpBinding0,net.tcp:/flocalhostlRouter 05); 06List<ServiceEndpointslepnewList<ServiceEndpoint>0;t 07lep.Add( 08newServiceEndpoint( 09ContractDescription.GetContract( 10typeof(lSimplexDatagramRouter) 11), 12newNetTcpBinding0, 13newEndpointAddress|nettcp://localhost:8080/Logger)

14) 15); 16RoutingConfigurationrcnewRoutingConfigurationO; 17rc.FilterTable.Add(newMatchAilMessageFilterO,lep); 18host.Description.Behaviors.Add(newRoutingBehavior(rc)); Requestreplyoperationsarefailing.Youneedtoensurethattheroutercanhandleonewayand requestreplyoperations.Whatshouldyoudo? A.Changeline03asfollows.Typeof(lRequestReplyRouter), B.Changeline03asfollows.Typeof(lDuplexSessionRouter), C.Changeline10asfollows.Typeof(lRequestReplyRouter) D.Changeline10asfollows.Typeof(lDuplexSessionRouter) Answer:B Question:16 AWindowsCommunicationFoundation(WCF)solutionusestwoservicestomanageashoppingcart ServiceAprocessesmessagescontaininglineitemsthattotalbetween$0ands500.ServiceB processesmessagescontaininglineitemsthattotalmorethan$50OAllmessagesareofequal importancetothebusinesslogicYouneedtorouteincomingmessagestotheappropriateservices byusingWCFroutingWhichtwomessagefiltersshouldyouaddtotherouter?(Eachcorrectanswer presentspartofthesolution,Choosetwo.) A.Amessagefilterwithapriorityof100thatwillforwardmessagesthattotalbetween$0ands500 toServiceA B.Amessagefilterwithapriorityof0thatwillforwardmessagesthattotalbetween$0ands500to ServiceA C.Amessagefilterwithapriorityof0thatwillforwardallmessagestoServiceB D.Amessagefilterwithapriorityof100thatwillforwardallmessagestoServiceB Answer:A,C

Вам также может понравиться