I am trying to access Microsoft Dynamics GP service.
Why is this happening?

This is my code (i got if from MSDN so should be fine):

CompanyKey companyKey;
Context context;
SalesOrder salesOrder;
SalesDocumentTypeKey salesOrderType;
CustomerKey customerKey;
BatchKey batchKey;
SalesOrderLine salesOrderLine;
ItemKey orderedItem;
Quantity orderedAmount;
Policy salesOrderCreatePolicy;

DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

context = new Context();

companyKey = new CompanyKey();
companyKey.Id = (-1);

context.OrganizationKey = (OrganizationKey)companyKey;

salesOrder = new SalesOrder();

salesOrderType = new SalesDocumentTypeKey();
salesOrderType.Type = SalesDocumentType.Order;

salesOrder.DocumentTypeKey = salesOrderType;

customerKey = new CustomerKey();
customerKey.Id = "AARONFIT0001";

salesOrder.CustomerKey = customerKey;
batchKey = new BatchKey();
batchKey.Id = "SALES ORDERS";

salesOrder.BatchKey = batchKey;
salesOrderLine = new SalesOrderLine();
orderedItem = new ItemKey();
orderedItem.Id = "32X IDE";

salesOrderLine.ItemKey = orderedItem;
orderedAmount = new Quantity();
orderedAmount.Value = 4;

salesOrderLine.Quantity = orderedAmount;
SalesOrderLine[] orders = { salesOrderLine };
salesOrder.Lines = orders;

Console.WriteLine("Call GetPolicyByOperation");
salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);

Console.WriteLine("Call CreateSalesOrder");
wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);

And my config:

?xml version="1.0" encoding="utf-8"?>
 
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
enabled="false" />
binding="wsHttpBinding" bindingConfiguration="GPWebService"
contract="DynamicsGP" name="GPWebService">

But i got:
The caller was not authenticated by the service. ---> System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed

Changed the


to


but now i got "The caller was not authenticated by the service. "

I used credentials

wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = @"asd";
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = "asd";
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "asd";
OR

wsDynamicsGP.ClientCredentials.UserName.UserName = @"asd";
wsDynamicsGP.ClientCredentials.UserName.Password = "asd";

But the same error. Another thing: i am logging in windows with this kind of username: comp\name and this is the name used as username, is this correct?

Another thing, my domain is different than theirs, this might be a problem?