Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The application encountered an unhandled system exception. Contact your system administrator for details.
- <?xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <system.serviceModel>
- <bindings>
- <wsHttpBinding>
- <binding name="GPWebService" closeTimeout="00:01:00"
- openTimeout="00:01:00" receiveTimeout="00:10:00"
- sendTimeout="00:01:00" bypassProxyOnLocal="false"
- transactionFlow="false" hostNameComparisonMode="StrongWildcard"
- maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
- messageEncoding="Text" textEncoding="utf-8"
- useDefaultWebProxy="true" allowCookies="false">
- <readerQuotas maxDepth="32" maxStringContentLength="8192"
- maxArrayLength="16384" maxBytesPerRead="4096"
- maxNameTableCharCount="2147483647" />
- <reliableSession ordered="true" inactivityTimeout="00:10:00"
- enabled="false" />
- <security mode="Message">
- <transport clientCredentialType="Windows"
- proxyCredentialType="None" realm="" />
- <message clientCredentialType="Windows"
- negotiateServiceCredential="true" algorithmSuite="Default"
- establishSecurityContext="true" />
- </security>
- </binding>
- </wsHttpBinding>
- </bindings>
- <client>
- <endpoint address="http://WSGP:48620/Dynamics/GPService/GPService"
- binding="wsHttpBinding" bindingConfiguration="GPWebService"
- contract="GPWebService.DynamicsGP" name="GPWebService">
- <identity>
- <userPrincipalName value="WSGPAdministrator" />
- </identity>
- </endpoint>
- </client>
- </system.serviceModel>
- </configuration>
- CompanyKey companyKey;
- Context context;
- SalesOrder salesOrder;
- SalesDocumentTypeKey salesOrderType;
- CustomerKey customerKey;
- BatchKey batchKey;
- SalesOrderLine salesOrderLine;
- ItemKey orderedItem;
- Quantity orderedAmount;
- Policy salesOrderCreatePolicy;
- // Create an instance of the service
- DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
- // Create a context with which to call the service
- wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = "Administrator";
- wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = "Server123";
- wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "WSGP";
- System.ServiceModel.WSHttpBinding binding;
- binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
- //wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "wsgp";
- 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 a sales order object
- salesOrder = new SalesOrder();
- // Create a sales document type key for the sales order
- salesOrderType = new SalesDocumentTypeKey();
- salesOrderType.Type = SalesDocumentType.Order;
- // Populate the document type key of the sales order object
- salesOrder.DocumentTypeKey = salesOrderType;
- // Create a customer key
- customerKey = new CustomerKey();
- customerKey.Id = "121001";
- // Set the customer key property of the sales order object
- salesOrder.CustomerKey = customerKey;
- // Create a batch key
- batchKey = new BatchKey();
- batchKey.Id = "RMS";
- // Set the batch key property of the sales order object
- salesOrder.BatchKey = batchKey;
- // Create a sales order line to specify the ordered item
- salesOrderLine = new SalesOrderLine();
- // Create an item key
- orderedItem = new ItemKey();
- orderedItem.Id = "8011172009618";
- // Set the item key property of the sales order line object
- salesOrderLine.ItemKey = orderedItem;
- // Create a sales order quantity object
- orderedAmount = new Quantity();
- orderedAmount.Value = 4;
- // Set the quantity of the sales order line object
- salesOrderLine.Quantity = orderedAmount;
- // Create an array of sales order lines
- // Initialize the array with sales order line object
- SalesOrderLine[] orders = { salesOrderLine };
- // Add the sales order line array to the sales order
- salesOrder.Lines = orders;
- // Get the create policy for the sales order object
- salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);
- // Create the sales order
- wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);
- // Close the service
- if (wsDynamicsGP.State != CommunicationState.Faulted)
- {
- wsDynamicsGP.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement