Try the below sample code instead of your above code for inventory transfer.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using DynamicsGPWebServiceSample.DynamicsGPService;
namespace DynamicsGPWebServiceSample
{
class Program
{
static void Main(string[] args)
{
CompanyKey companyKey;
Context context;
BatchKey batchKey;
ItemKey itemKey;
Quantity itemQuantity;
WarehouseKey fromWarehouseKey;
WarehouseKey toWarehouseKey;
InventoryKey inventoryKey;
InventoryLineKey inventoryLineKey;
InventoryTransfer inventoryTransfer;
InventoryTransferLine inventoryTransferLine;
Policy inventoryTransferCreatePolicy;
// Create an instance of the service
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
// Create a context with which to call the service
context = new Context();
// Specify which company to use (sample company)
companyKey = new CompanyKey();
companyKey.Id = (-1);
// Set up the context object
context.OrganizationKey = (OrganizationKey)companyKey;
// Create an inventory key to identify the inventory transfer object
inventoryKey = new InventoryKey();
inventoryKey.Id = "WSINVTRFR00000010";
// Create a batch key object to specify a batch for the inventory transfer
batchKey = new BatchKey();
batchKey.Id = "TRANSFER 1";
// Create an inventory transfer object
inventoryTransfer = new InventoryTransfer();
// Populate the inventory transfer object's required properties
inventoryTransfer.Key = inventoryKey;
inventoryTransfer.BatchKey = batchKey;
inventoryTransfer.Date = DateTime.Today;
// Create an inventory transfer line object to detail the inventory transfer
inventoryTransferLine = new InventoryTransferLine();
// Create an inventory line key to identify the inventory transfer line object
inventoryLineKey = new InventoryLineKey();
inventoryLineKey.InventoryKey = inventoryKey;
// Create an item key object to specify the item
itemKey = new ItemKey();
itemKey.Id = "128 SDRAM";
// Create a quantity object to specify the amount of the transfer
itemQuantity = new Quantity();
itemQuantity.Value = 5m;
// Create a warehouse key to specify the location originating the transfer
fromWarehouseKey = new WarehouseKey();
fromWarehouseKey.Id = "WAREHOUSE";
// Create a warehouse key to specify the location receiving the transfer
toWarehouseKey = new WarehouseKey();
toWarehouseKey.Id = "WAREHOUSE";
// Populate the required properties of the inventory transfer line object
inventoryTransferLine.Key = inventoryLineKey;
inventoryTransferLine.ItemKey = itemKey;
inventoryTransferLine.Quantity = itemQuantity;
inventoryTransferLine.WarehouseFromKey = fromWarehouseKey;
inventoryTransferLine.WarehouseToKey = toWarehouseKey;
// Create an array to hold the inventory transfer line object
InventoryTransferLine[] lines = { inventoryTransferLine };
// Add the array of inventory transfer lines to the inventory transfer object
inventoryTransfer.Lines = lines;
// Get the create policy for an inventory transfer
inventoryTransferCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
"CreateInventoryTransfer", context);
// Create the inventory transfer
wsDynamicsGP.CreateInventoryTransfer(inventoryTransfer,
context, inventoryTransferCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}
Note: I don't have web services on my environment. So, couldn't provide the exact code. Try the above sample code. Replace the hard coded values with your input values and additionally create the quantity type object to pass the fromQtyType and toQtyType.
Hope this helps!!!