WEB SERVICES Service Tier Client Tier High Level
WEB SERVICES
Service Tier Client Tier High Level Architecture Role Tailored Client Form Builder Data Binder Web Services Client Services Application Meta data provider Database Tier Class Library Microsoft SQL Server 3 T architecture Service. Tier 95% managed code Only small part of kernel is unmanaged Application is compiled to managed code Business Logic executes on Service Tier “No code” on the Client Only OCX’s and COM objects SQL Reporting Services Still support for Classic Reports Web Services…
Web. Services - the simple story • Pages and Codeunits can be exposed as webservices and used by any webservice consumer Consumer uses Windows Authentication – Supports SSL D EM O –
Strongly typed WS access • Examples Adding orders from a Web portal – Invoking Business Logic – Search functionality – • Using Typically using specially designed Pages & Codeunits – Visual studio and C# – Running client side (Integration) – Running server side (webapp / process) D EM O –
Initializing the service Customer_Service service = new Customer_Service(); service. Use. Default. Credentials = true;
Creating a filter specification Customer_Service service = new Customer_Service(); service. Use. Default. Credentials = true; Customer_Filter filter = new Customer_Filter(); filter. Field = Customer_Fields. Location_Code; filter. Criteria = "=YELLOW";
Reading the data Customer_Service service = new Customer_Service(); service. Use. Default. Credentials = true; Customer_Filter filter = new Customer_Filter(); filter. Field = Customer_Fields. Location_Code; filter. Criteria = "=YELLOW"; Customer[] customers = service. Read. Multiple(new Customer_Filter[] { filter }, null, 0);
Filling the listbox Customer_Service service = new Customer_Service(); service. Use. Default. Credentials = true; Customer_Filter filter = new Customer_Filter(); filter. Field = Customer_Fields. Location_Code; filter. Criteria = "=YELLOW"; Customer[] customers = service. Read. Multiple(new Customer_Filter[] { filter }, null, 0); foreach (Customer customer in customers) { this. list. Box 1. Items. Add(customer. No + " " + customer. Name + " " + customer. Location_Code); }
Open RTC page with bookmark string bookmark = service. Get. Bookmark(customer. Key); System. Diagnostics. Process. Start("Dynamics. NAV: ////Run. Page? Page=21 &mode=View&Bookmark=" + bookmark); AL-Code for getting a RTC compatible bookmark: bookmark : = FORMAT(ref. RECORDID, 0, 10);
Loosely coupled WS access • Examples – Edit in Excel • Using Generic Page access – Typically Client integration stuff – • Pitfalls EM O Limited metadata available for pages D –
Get Discovery XMLHTTP xh. Disco = new XMLHTTP(); xh. Disco. open("GET", Send. URL, false, Domain. User, Password); xh. Disco. send(null); if (xh. Disco. status != 200) { Message. Box. Show(xh. Disco. status. To. String() + ": " + xh. Disco. status. Text); return; } Xml. Document xd. Disco = new Xml. Document(); xd. Disco. Load. Xml(xh. Disco. response. Text);
POST Read. Multiple command XMLHTTP xh 4 = new XMLHTTP(); xh 4. open("POST", Send. URL, false, null); xh 4. set. Request. Header("Content-Type", "text/xml; charset=utf-8"); xh 4. set. Request. Header("SOAPAction", "Read. Multiple"); xh 4. send(soap. Request); Xml. Document rs 4 = new Xml. Document(); rs 4. Load. Xml(xh 4. response. Text);
Read. Multiple XML <? xml version="1. 0" encoding="utf-8"? > <soap: Envelope xmlns: soap="http: //schemas. xmlsoap. org/soap/envelope/"> <soap: Body> <Read. Multiple xmlns="urn: microsoft-dynamics-schemas/page/customer"> <filter> <Field>Balance_LCY</Field> <Criteria>> 10, 000</Criteria> </filter> </Read. Multiple> </soap: Body> </soap: Envelope>
Update XML <? xml version="1. 0" encoding="utf-8"? > <soap: Envelope xmlns: soap="http: //schemas. xmlsoap. org/soap/envelope/"> <soap: Body> <Update xmlns="urn: microsoft-dynamics-schemas/page/customer"> <Customer> <Key>300; Eg. AAAACJCDAx. NDU 0 NTQ 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=19; -3546584706554265600; </Key> <No>01454545</No> <Name>New Concepts Furniture</Name> <Address>705 West Peachtree Street</Address> ………… </Customer> </Update> </soap: Body> </soap: Envelope>
Do's and Don'ts • Only expose Web. Services • Microsoft Dynamics NAV to the internet through a 2009 Web. Services should “proxy” (either not be exposed directly to Web. Services or a Portal the internet App. ) • Avoid long running • Use GUIALLOWED and transactions ISSERVICETIER to control flow • Create special pages/codeunits for your strongly typed WS access
GUIALLOWED vs. ISSERVICETIER • Use GUIALLOWED in your code to determine whether your code allows user interaction – WS & NAS will have GUIALLOWED = false • Use ISSERVICETIER in your code to determine whether your code is running managed code on the servicetier or interpreted AL Code on a client or NAS – WS & RTC will have ISSERVICETIER = true
Transactions • Invoke WS method == One transaction Commits are ignored – Locks are kept until WS method runs out of scope – • Structure your tables and your code – Don’t do multiple inserts in one go
Multiple Service Tiers on one box P X SC <machine> create Nav<name> binpath= “<exepath> <name>” displayname= “Nav Server <name>” type= own start= auto depend= Net. Tcp. Port. Sharing w t k r o n o SC <machine> create Nav. WS<name> binpath= “<exepath> <name>” displayname= “Nav Server <name> WS” type= share start= auto depend= Net. Tcp. Port. Sharing/HTTP r t ce i rv e S ’ n D o s e e n e is L r ie T te r e n W eb r e S e c vi s Li
Performance • Web. Service and Service Tier caches Metadata – JIT Compiled C# code – • Caches are flushed when services are restarted • Cold access to objects are very slow
JIT compile directory C: Documents and SettingsAll UsersApplication DataMicrosoft Dynamics NAV60Server D O M E
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U. S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
- Slides: 21