Hello Martin,
In our enterprise, we have a web based application and also has Dynamics AX 2012 R3 CU8.
In web application, once there is one SO created, web application sends that information to Dynamics AX 2012 R3 by passing the XML to the AIF webservice in AX 2012 R3.
Both web application and Dynamics AX 2012 R3 are in the same domain. The AIF web service is hosted on .NET adaptor in AX 2012.
Now our web team has provided the XML which they normally pass to Dynamics. We are trying to pass and test that XML using the .NET code.
Below is the screen shot of the AIF adaptor and the corresponding service.
Sales Order group:
Sales order service:
Below is the sample code which we are trying to create the Sales order by passing some sample hardcoded values (as we do not have any code how to pass the XML in to AIF webservice via .NET).
/*using System;
namespace TestAIFSOService
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestAIFSOService;
using ServiceReference2;
using System.Threading.Tasks;
namespace TestAIFSOService
{
class Program
{
static void Main(string[] args)
{// Instantiate an instance of the service client class.
SalesOrderServiceClient proxy = new SalesOrderServiceClient();
// Create an instance of the document class.
AxdSalesOrder salesOrder = new AxdSalesOrder();
// Create instances of the entities that are used in the service and
// set the needed fields on those entities.
ServiceReference2.AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();
salesTable.CurrencyCode = "USD";
salesTable.CustAccount = "C846456";
salesTable.ReceiptDateRequested = Convert.ToDateTime("4/21/2020");
salesTable.Payment = "PP";
AxdEntityKey_LogisticsPostalAddress LPA = new AxdEntityKey_LogisticsPostalAddress();
LPA.Location_LocationId = "5637282089";
AxdExtType_EffectiveDateTime date = new AxdExtType_EffectiveDateTime();
date.timezone = AxdEnum_Timezone.GMT_COORDINATEDUNIVERSALTIME;
DateTime dateValue = new DateTime(2015, 4, 29, 14, 10, 53, 001, DateTimeKind.Utc);
date.timezoneSpecified = false;
date.localDateTimeSpecified = false;
date.Value = dateValue;
LPA.ValidFrom = date;
salesTable.DeliveryPostalAddress = LPA;
AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();
salesLine.ItemId = "10-009";
salesLine.SalesQty = 9;
salesLine.SalesUnit = "ea";
CallContext callContext = new CallContext();
//GG-Added the code
// SalesOrderServiceClient client = new SalesOrderServiceClient();
//GG-End the code
callContext.Language = "en-us";
callContext.Company = "HYD"; //"KTEC";
//callContext.LogonAsUser
salesOrder.SalesTable = new AxdEntity_SalesTable[1] { salesTable };
salesTable.SalesLine = new AxdEntity_SalesLine[1] { salesLine };
//
proxy.ChannelFactory.Credentials.UserName.UserName = "mydomain\\myusername";
proxy.ChannelFactory.Credentials.UserName.Password = "mypassword";
try
{
// Call the create method on the service passing in the document.
EntityKey[] returnedSalesOrderEntityKey = proxy.create(callContext, salesOrder);
// The create method returns an EntityKey which contains the ID of the sales order.
EntityKey returnedSalesOrder = (EntityKey)returnedSalesOrderEntityKey.GetValue(0);
Console.WriteLine("The sales order created has a Sales ID of " + returnedSalesOrder.KeyData[0].Value);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}
}
}
}
and getting the below error message,
+ e {"Transport security negotiation failed due to an underlying IO error: Unable to read data from the transport connection: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:10:00'..."} System.Exception {System.ServiceModel.Security.SecurityNegotiationException}
but our end goal is to pass the XML in .NET code and create a Sales order in AX (Also if we can debug the code in AX, that would also be very helpful).
Regards