![]() |
#1 |
Участник
|
If you haven’t already read part 4 (and the prior parts) you should do so here, before continuing to read this post.
In this post, I am going to create a small Windows Phone 7 application, which basically will be a phone version of the sidebar gadgets from this post. When we are done, your Windows Phone 7 will look like: ![]() During the other posts, I have been describing how to make the Proxy and one way of securing this. For this sample, I have created a new Proxy (Proxy2) and added 3 functions to this proxy: Customer[] GetMyCustomers(string username, string password) Vendor[] GetMyVendors(string username, string password) Item[] GetMyItems(string username, string password) You can imagine that these functions are implemented in the Proxy simply by authenticating and calling the corresponding function in the MyStuff codeunit from this post, I will not go into further detail about how the Proxy is done. A small Console Application Try the following:
static void Main(string[] args)
![]() This in effect calls my NAV proxy2 (which is placed in Redmond) through the Service bus and returns My Customers. I will try to keep the server running, but please understand that it might be down for various reasons (I might be doing development work on the Proxy). A Windows Phone 7 application Now for the real thing. In order to create solutions for Windows Phone 7, you will need the developer tools and they can be downloaded for free here: http://create.msdn.com/en-us/home/getting_started: There are three steps to the install process:
![]() Anyway – when done – you are ready. I created a Windows Phone Panorama Application from the templates: ![]() After this, I add a service reference to the Proxy (sb://navdemo.servicebus.windows.net/Proxy2/mex) with the namespace Proxy2. Looking at the ServiceReferences.ClientConfig, you will see that only the http:// and the https:// endpoints are mentioned here as the Windows Phone doesn’t support sb://. In Windows Phone applications it is common to have a ViewModel, which is the data for the app. The templates comes with a default ViewModel, which we need to modify: Declaring the collections: /// <summary> /// Collections for My stuff objects. /// </summary> public ObservableCollection<Proxy2.Customer> MyCustomers { get; private set; } public ObservableCollection<Proxy2.Vendor> MyVendors { get; private set; } public ObservableCollection<Proxy2.Item> MyItems { get; private set; } Initializing the ViewModel: public MainViewModel() { this.MyCustomers = new ObservableCollection<Proxy2.Customer>(); this.MyVendors = new ObservableCollection<Proxy2.Vendor>(); this.MyItems = new ObservableCollection<Proxy2.Item>(); } Loading the data: /// <summary> /// Load data into collections /// </summary> public void LoadData() { BasicHttpBinding binding; EndpointAddress endpoint; // Emulator doesn’t support HTTPS reliably binding = new BasicHttpBinding(BasicHttpSecurityMode.None); endpoint = new EndpointAddress("http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|