AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 24.04.2013, 08:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
emeadaxsupport: How to implement basic authentication with Dynamics Ax 2012 web services
Источник: http://blogs.msdn.com/b/axsupport/ar...-services.aspx
==============

Important: This sample is not a production ready solution. As described below the user credentials will be passed in plain text which is not ideal in a production environment. To prevent this from occurring it would be recommended to incorporate SSL with this solution.


  1. Create inbound HTTP port.
    1. Navigate to System administration->Setup->Services and Application Integration Framework->Inbound ports.
    2. Create an inbound port using the HTTP adapter with settings similar to the image below.
Basic settings:



Service operations:


  1. Activate the new inbound port.
  2. We need to configure the client configuration. In order to do this you need to select the ‘Configure’ button. Note: Do not select the ‘Configure AOS’ button.
  3. You should see a dialog with a warning. Just click yes to continue loading the configuration file.
  4. Locate the Bindings section under the Configuration frame and select ‘New Binding Configuration’ from the Bindings frame.
  5. Select ‘basicHttpBinding’ and click OK.
  6. In the ‘Name’ field enter ‘basicHttpBindingWithBasicAuth’.

  1. Click the ‘Security’ tab and set the attributes as shown below.

  1. Locate the ‘reqReplyEndpoint’ in the Configuration frame, and highlight it.
  2. Change the BindingConfiguration attribute for the endpoint from ‘basicHttpBindingWithWindowsAuth’ to ‘basicHttpBindingWithBasicAuth’.



  1. Save the configuration file and close the WCF configuration editor.
  2. Activate the SalesOrderHTTPService port.
  3. Open IIS manager and navigate to the MicrosoftDynamicsAXAif60 virtual directory. Highlight it, and from the main frame open ‘Authentication’ from the IIS group.
  4. Enable Basic Authentication. Your settings should look like that below.

  1. Close IIS manager and complete an iisreset from a command prompt.
  2. Open Visual Studio.
  3. Select File->New->Project. From the New Project dialog select Windows Forms Application. Enter a name for the project (e.g. SalesOrderTest). Click OK.

  1. Once the project opens drag a button from the toolbox onto the form.

  1. Add the Sales Order Service reference to the project. Note: You can pull the address from the ‘Inbound ports’ form within Dynamics Ax.
Important: You will be asked for credentials in order to access the service and metadata. I entered my administrator account and password until the RoutingService showed in the Services frame below, then cancelled all remaining authentication dialogs. This will only work if you have Windows and Basic authentication enabled on your IIS box for the AIF virtual directory.




  1. Close IIS manager. Open a command prompt and complete an iisreset.
  2. Open Visual Studio and open your project back up.
  3. Double-click the Button on the form to open the code window and create a new button_click event.
  4. Add a ‘using’ statement for the sales order web service.

  1. Within the newly created button click event paste the following code.
SalesOrderServiceClient proxy = new SalesOrderServiceClient();

proxy.ChannelFactory.Credentials.UserName.UserName = @"domain\user";

proxy.ChannelFactory.Credentials.UserName.Password = @"password";



CallContext context = new CallContext();

context.Company = "ceu";



AxdSalesOrder salesOrder = new AxdSalesOrder();

AxdEntity_SalesTable[] salesTables = new AxdEntity_SalesTable[1];

AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();



salesTable.CurrencyCode = "USD";

salesTable.CustAccount = "1103";

salesTable.ReceiptDateRequested = Convert.ToDateTime("2/1/2012");

salesTable.Payment = "N060";

salesTable.PurchOrderFormNum = "PO113";





#region Financial Dimensions



AxdType_DimensionAttributeValue dimBusinessUnit = new AxdType_DimensionAttributeValue();

dimBusinessUnit.Name = "BusinessUnit";

dimBusinessUnit.Value = "20";





AxdType_DimensionAttributeValue dimCustomerGroup = new AxdType_DimensionAttributeValue();

dimCustomerGroup.Name = "CustomerGroup";

dimCustomerGroup.Value = "10";





AxdType_DimensionAttributeValue dimDepartment = new AxdType_DimensionAttributeValue();

dimDepartment.Name = "Department";

dimDepartment.Value = "500";



AxdType_DimensionAttributeValueSet valueSet = new AxdType_DimensionAttributeValueSet();

valueSet.Values = new AxdType_DimensionAttributeValue[3] { dimBusinessUnit, dimCustomerGroup, dimDepartment };

salesTable.DefaultDimension = valueSet;

#endregion



AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();

salesLine.ItemId = "1000";

salesLine.SalesQty = 1;

salesLine.SalesUnit = "ea";





AxdEntity_SalesLine salesLine2 = new AxdEntity_SalesLine();

salesLine2.ItemId = "1000";

salesLine2.SalesQty = 55;

salesLine2.SalesUnit = "ea";



AxdEntity_SalesLine salesLine3 = new AxdEntity_SalesLine();

salesLine3.ItemId = "10004";

salesLine3.SalesQty = 21;

salesLine3.SalesUnit = "Pcs";



AxdEntity_InventDim inventDim = new AxdEntity_InventDim();

inventDim.InventSiteId = "1";

salesLine3.InventDim = new AxdEntity_InventDim[1] { inventDim };



salesTable.SalesLine = new AxdEntity_SalesLine[3] { salesLine, salesLine2, salesLine3 };

salesOrder.SalesTable = new AxdEntity_SalesTable[1] { salesTable };



try

{

proxy.create(context, salesOrder);

MessageBox.Show("Worked");

}



catch (Exception ex)

{

throw ex;

}


  1. Open IIS manager and navigate to the MicrosoftDynamicsAXAif60 virtual directory. Highlight it, and from the main frame open ‘Authentication’ from the IIS group.
  2. Disable Windows Authentication. Your settings should look like that below.

  1. Close IIS manager and complete an iisreset from a command prompt.
  2. Build and test the program.
Note: The data presented in the sample above may not coincide with your existing database. You may have to update the code to validate against your AX setup. If you do not update the sample code you are likely to get a validation error returned from the server.




Источник: http://blogs.msdn.com/b/axsupport/ar...-services.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 12 Blog bot Dynamics CRM: Blogs 0 30.01.2013 01:11
emeadaxsupport: Microsoft Dynamics AX 2012 Form based Authentication provider has wrong connection string when the aspnetdb is created on a separate server. Blog bot DAX Blogs 0 12.09.2012 19:11
AIF: Microsoft Dynamics AX 2012 Services and AIF White Papers Blog bot DAX Blogs 0 16.06.2011 00:11
dynamics-ax: Interview with Microsoft's Lachlan Cash on his new role, AX 2012 and more Blog bot DAX Blogs 6 22.04.2011 14:55
daxdilip: Whats New in Dynamics AX 2012 (A brief extract from the recently held Tech Conf.) Blog bot DAX Blogs 7 31.01.2011 12:35

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:10.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.