You are on page 1of 10

INTEGRATE

Microsoft Dynamics GP

Using Web Services for Microsoft Dynamics GP in Business Portal


White Paper How to use Visual Studio 2005 and Web Services for Microsoft Dynamics GP 10.0 to create a new Business Portal web part.

Date: September 26, 2007

Table of Contents
Introduction ....................................................................................................................... 3 Internet Information Services (IIS) configuration ......................................................... 3
Uninstall Web Services for Microsoft Dynamics GP:...........................................................................................................3 Create a new web site: ...................................................................................................................................................................4 Reinstall Web Services for Microsoft Dynamics GP:............................................................................................................4 Add the Microsoft Windows user to the BDC Administrator role:...........................................................................5

Visual Studio 2005 Web Site custom application .......................................................... 6 Exposing the custom application in Business Portal .....................................................8 How to use Company Database ID in custom application............................................ 9
Microsoft Business Framework Method: .................................................................................................................................9 Office SharePoint Server Method: .............................................................................................................................................9

2 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

Introduction
This document provides the developer a sample solution that demonstrates how to add new functionality into Business Portal for Microsoft Dynamics GP 10.0. In this scenario, we use Visual Studio 2005 and Web Services for Microsoft Dynamics GP 10.0 to create a web part that creates Sales Quotes from the Sales Quote List page in Business Portal. The custom Enter Sales Quotes web part is shown below in the Sales Quote List page:

Internet Information Services (IIS) configuration


If Business Portal and Web Services for Microsoft Dynamics GP will be installed on the same web server, these programs need to be installed in their own web sites. The following steps describe how to move the web site for Web Services for Microsoft Dynamics GP to a new site. (For more information, refer to Knowledge Base article 920903).

Uninstall Web Services for Microsoft Dynamics GP:


1. 2. 3. 4. From the Start menu, choose Control Panel, and then choose Add or Remove Programs. Select Web Services for Microsoft Dynamics GP, and then click Change. Click Remove. Do not mark the Remove SQL Objects and Data check box. Click Next.

3 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

Create a new web site:


1. 2. 3. 4. 5. 6. From the Start menu, choose Administrative Tools, and then choose Internet Information Services (IIS) Manager. Expand the local computer name in the left pane, and then right-click Web Sites. Choose New, and then choose Web Site. In the Web Site Creation wizard, click Next. On the Web Site Description page, enter a description for the site, such as "Web services." Click Next. On the IP Address and Port Settings page, enter a port number other than port 80. Alternatively, enter a host header, such as Web services. Note: Port 80 is the default port number for the Default Web Site. Only one web site can use a specific port number unless you specify a host header for the new site. That host header lets IIS correctly route requests to the appropriate sites. See the IIS documentation for more information about port numbers and host headers. 7. 8. 9. Click Next. On the Web Site Home Directory page, enter the path of the folder in which you want to create the new web site. This folder can be in any location, or you can create a new folder. Clear the Allow anonymous access to this web site check box.

10. Click Next. 11. On the Web Site Access Permissions page, mark the Read check box, the Run scripts check box, and the Execute check box. 12. Click Next to complete the wizard and to create the new web site.

Reinstall Web Services for Microsoft Dynamics GP:


1. Reinstall Web Services for Microsoft Dynamics GP to the site that you created in the previous procedure. Use the installation procedure described in the Microsoft Dynamics GP Web Services Installation and Administration Guide. Verify the new URL in a web browser. You can access the web site for Web Services for Microsoft Dynamics GP by using one of the following URLs, depending on whether you specified a port or a host header when you created the site: http://<computer_name:port>/DynamicsGPWebServices http://<host_header>/DynamicsGPWebServices

2.

4 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

Add the Microsoft Windows user to the BDC Administrator role:


The Business Data Catalog web parts in Business Portal use Web Services for Microsoft Dynamics GP. It is necessary to use the Dynamics Security Console to add the Windows user running the Application pool for the Business Portal web site into the BDC Administrator role. To determine the Application Pool for the Business Portal web site, right click on the web site and choose Properties, and then display the Home Directory tab. If you are not sure which web site is the Business Portal web site, click each web site to look for a virtual directory called BusinessPortal.

To add the Windows user to the BDC Administrator role, complete the following steps: 1. 2. 3. 4. 5. 6. Open the Dynamics Security Console on a computer where the console is installed. From the Start menu, choose Administrative Tools, and then choose Dynamics Security Console. Select the Role Assignments node in the left pane of the Dynamics Security Console. From the Action menu, choose Add. The Add Role Assignments window will appear. In the Role list, select the BDC Administrator role. Click Add Windows Users to add individual windows users to the role assignment. Select the desired company or all companies and click OK to save the new role assignment.

5 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

Visual Studio 2005 Web Site custom application


The custom application is an ASP.NET web site application created with Visual Studio 2005. A web reference in the project is made to the DynamicsGPService.asmx page to access the WSDL (Web Services Description Language) of the Dynamics GP Web Service. The web site application is made up of a simple Default.aspx page that has four text box controls, two button controls, and some labels. The Default.aspx page references a DataMgr class that handles calling the web service. The attached code is for the Default.aspx.cs and DataMgr.cs files. Note: To view attachments, you must be viewing this document in Adobe Reader 6.0 or later, or in the full version of Acrobat. Right-click the paperclip icon to the left of the desired file, and choose to open or save the file. Default.aspx.cs.txt DataMgr.cs.txt

When it is time to publish the web site, make sure the following options are marked: Allow this precompiled site to be updatable Enable strong naming on precompiled assemblies Mark assemblies with AllowPartiallyTrustedCallerAttribute

The following illustration shows the Publish Web Site window in Visual Studio 2005. (To view this window, choose Build from the Publish Web Site menu.)

Steps for using the Strong Name tool to create a key file are located at http://msdn2.microsoft.com/enus/library/6f05ezxy(vs.80).aspx. It is necessary to follow these steps when publishing the web site so the web part will display correctly. Windows SharePoint Services 3.0 will need to trust the new assemblies that are generated from the Publish Web Site process. In addition to the Publish Web Site steps, you will need to add a new code group to the WSS_minimaltrust.config file, using the following steps: 1. 2. 3. From the Start menu, choose Administrative Tools, and then choose Microsoft .NET 2.0 Configuration. Expand Runtime Security Policy, expand Machine, expand Code Groups, expand All Code, and then expand My_Computer_Zone. Right-click My_Computer_Zone, and then choose New.
6 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

4. 5. 6. 7. 8. 9.

In the Create Code Group window, give the group a name such as WSStrongName. Click Next. In the Choose Condition Type window, click Strong Name, click Import, and then locate the .dll file that contains the digitally signed assembly. A public key appears on the window. Click Next, click Existing Permission Set, and then click Full Trust. Click Next. Click Finish. This step creates a code group for that key.

10. Locate the C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG folder on the computer where you created the code group. 11. Open the Security.config file, and then copy the code group nodes that contain the new group. For example, a code group node resembles the following:
version="1" PermissionSetName="FullTrust" Name="BPSDKStrongName" Description=""> version="1" PublicKeyBlob="00240000048000009400000006020000002400005253413100040000010001004DC871C3C1549 B921CA9417CF9FE423F0FBF8B98720EF7C8C1988945FF5B45D4934594201C9FE886F36B20C0976AFF63DCAC196 1E7287616AA7C79B97273F14CD659436A2FD3AEEBA048D3E01AE3A834F31615CA97B8FFEF03726C2D09F00014 692D63824E7328EBDD92C4E63FDB8F9A35B90AACBD6E2A1FC2D87B41B228F9BB"/>

12. Locate the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Config folder, open the WSS_minimaltrust.config file, and then locate the following code group.
version="1" PermissionSetName="FullTrust" Name="MBFStrongName" Description=""> version="1" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67 871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE602 1672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F59 6836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9"/>

13. Paste the code group nodes that you copied in step 11 into the WSS_minimaltrust.config file immediately after the code group that you located in step 12. This is a critical step. If the code group is not put in the correct location, the code and the Business Portal assemblies will not be trusted. 14. Save the WSS_minimaltrust.config file. 15. Copy the strong named assemblies to the Bin folder of the Business Portal web site and the aspx pages to the desired location.

7 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

Exposing the custom application in Business Portal


Since the custom application allows a user to enter Sales Quotes, the location of the custom application will be on the Sales Quote List page under the Sales Center site. The custom application will be rendered in a Page Viewer web part. The default.aspx page will be located in the BusinessPortal virtual directory. The default location is at C:\Program Files\Microsoft Dynamics\Business Portal\Applications. The following screen shot illustrates the Page Viewer web part points to a new folder called SalesQuoteMgmt. The path is /BusinessPortal/Applications/SalesQuoteMgmt:

A benefit of storing the custom application pages in the BusinessPortal virtual directory is the ability to leverage the Business Portal session information. In this example, the custom application is leveraging the users Business Portal session to attain the company database ID and set the OrganizationKey of the Context object in the Dynamics GP Web Service call. The code files attached below provide examples of using the Microsoft Business Framework and Office SharePoint Server assemblies. The Office SharePoint Server assembly method can be used when Business Portal is installed in a Microsoft Office SharePoint Server environment. Note: To view attachments, you must be viewing this document in Adobe Reader 6.0 or later, or in the full version of Acrobat. Right-click the paperclip icon to the left of the desired file, and choose to open or save the file. MBFMethod.txt OSSMethod.txt

8 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

How to use Company Database ID in custom application


Use the method appropriate for your installation type.

Microsoft Business Framework Method:


1. 2. 3. 4. Open the project using Visual Studio 2005. In Solution Explorer, right-click on the project and choose Add Reference. View the Browse tab and locate the Microsoft.BusinessFramework.dll. Click OK. (This assembly is located in the Bin folder of the Business Portal web site.) Add the following using directives:
using Microsoft.BusinessFramework using Microsoft.BusinessFramework.Entity;

5. 6.

Add the code from the MBFMethod.txt file to the class in the project. Notice that the CompanyKey of the Web Services is set to the value returned by the GetDBID() method. Build and publish the web site application, following the recommendations in this document.

Office SharePoint Server Method:


1. 2. 3. 4. Open the project using Visual Studio 2005. In Solution Explorer, right-click on the project and choose Add Reference. View the Browse tab and locate the Microsoft.Office.Server.dll. Click OK. (The default location is C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI) Add the following using directive:
using Microsoft.Office.Server.UserProfiles;

5. 6.

Add the code from the OSSMethod.txt file to the class in the project. Notice that the CompanyKey of the Web Services is set to the value returned by the GetDataBaseOSS() method. Build and publish the web site application, following the recommendations in this document.

9 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, this document should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. 2007 Microsoft Corporation. All rights reserved. Microsoft, the Microsoft Dynamics Logo, Microsoft Dynamics, SharePoint, Visual Studio, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

10 USING WEB SERVICES FOR MICROSOFT DYNAMICS GP IN BUSINESS PORTAL

You might also like