首页 > > 详细

5ENT1070作业代做、代写Web Services作业、CS编程语言作业调试、CS课程作业代写代做Java程序|调试C/C++编程

5ENT1070 – Web Services
Using WCF in UWP
Aims
• Integrate the WCF functionality into UWP
• Test they work and submit your WCF and UWP solutions on StudyNet
Task 1 – Adding your WCF solution to a UWP solution
• Copy your previous WCF and UWP solutions to Desktop and open both with separate Visual
Studio windows.
o This should be the WCF solution from the lab “Adding User Authentication to WCF”.
• Run your WCF solution with the Service1.svc.cs file open, to see the Test Client.
• Right click on the URL at the top of the service tree and click Copy Address.
• Now leave this running and open the visual studio window with your UWP solution.
o Right click on your project and go to Add -> Service Reference…
• In the Address bar of the Add Service Reference window, paste the URL you copied from the
Test Client and click Go.
• You will see Service1 appear in the Services box if successful.
o If not make sure you have the WCF running.
• Change the NameSpace before you click ok to your own choice of name, but NOT the
namespace of your program.
o I have chosen HouseService (No spaces), you can use the same name if you wish.
• Then click OK.
• You will now see in the section Connected Services, that you have your service added.
o If at any time you make a change to the WCF, you must re-run the WCF then right
click on the service instance in your UWP Solution Explorer and Update it.
Task 2 – Use your Service in UWP
• The first thing we will do is test this is going to work, by using the service in the most basic
way…
o Open your UWP solution file for MainPage.xaml.cs.
o Near the top of the code, find where your MainPage class is declared and add a
Global Declaration for your HouseService’s Client Object.
o Locate your click event that should be for a login button.
▪ If this method does not exist, you must add a button to your MainPage.xaml
and generate the click event for this!
o Within this method we are going to use the object we’ve created called “service” to
run the GetData() method.
▪ We will hard-code the information to start with before we have user
entered data.
▪ Use a house ID that you have in your table and also use a user account that
has permission.
▪ Add a breakpoint as indicated also, as we will use this to prove it has
worked.
o Now run the program and click on the button you have used the click method for.
▪ The code will stop at the breakpoint, at which point you can click on the
result and expand a view of the data.
▪ If there was a problem it will show null, in which case use the Test Client to
debug this.
Task 3 – Public User Verification
Our User Verification method in WCF is currently private, to allow login without any other data
requests, we need to change this and add the method as an OperationContract in the IService1.cs
file.
• Stop both the WCF and UWP programs.
• Open your Service1.svc.cs file and locate your validateUser() method.
• Change the identifier from private to public
• Now open your IService1.cs file and add this method as an operation contract
o You can copy and paste the line from int to the ‘)’ character.
• Now open the Service1.svc.cs and then run the solution.
• Then open your window for the UWP solution, right click on your Service Reference and click
“Update Service Reference…”.
o When complete, your UWP now has the changes made to the validateUser method.
• Open your App.xaml.cs file and create three static variable as Global Declarations as shown
below:
o These variables will be for storing our login info from the MainPage…
• Open your MainPage.xaml file and locate the third button in your SplitView navigation (in
the lab document it was called thirdButton).
• Add an “isEnabled” parameter to this button and make it false.
• Do the same thing for the DevicePage also.
o When successful you will see the button appear grey in the design view.
• Return back to the MainPage.xaml.cs file and locate your Login button’s click method again.
• This method will now be used to validateUser with the database and enable the thirdButton
in the navigation pane.
o Change your code in this login click method to match the following:
o Don’t miss the “async” word in the method declaration itself!
• Now in the same file, scroll up and find your MainPage() method and create an IF statement
that will enable the thirdButton is the App.isLoggedIn value is true…
• Make the same change in the DevicePage.xaml.cs file!
• Now run the UWP and test your login works.
o Don’t forget to make sure your WCF is also running.
o If successful you will see the database button enable when the correct login is
entered, or a message box pop up when the wrong info is entered.
Task 4 – Add data to database from USB Device
Now that you know how to use methods in your WCF, add some Controls to your device page of
your UWP, which allow a user to manually input data (There should be enough controls to allow
input of every piece of data required for your database table). Then add a submit button of some
sort, which will add this data into your database using your insertData() method, from the Click
event.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2
热点文章
程序代写更多图片

联系我们 - QQ: 99515681 微信:codinghelp2
© 2014 www.7daixie.com
程序代写网!