function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steven Murphy 6Steven Murphy 6 

C# SOAP API Update

First off, I have just started learning the SOAP API using Visual Studio and C#. I am seeing many differences between the SOAP API documentation and the actual method signatures in the Enterprise WSDL. I don't know whether the docmentation is out of date, or I did something wrong in the WSDL generation.

Anyway, I have corrected the sample code for logging in and out and running queries, but I've hit a wall when trying to update an Opportunity Line Item record. The code below runs, and the SaveResult indicates success, but the record does not get updated.

Am I on the right track here, or do I have a problem in my service reference?
 
if(Login())
                {
                    string lineItemId = GetOpportunityLineItemId();

                    OpportunityLineItem lineItem = new OpportunityLineItem();
                    lineItem.Id = lineItemId;
                    lineItem.Quantity = 2;

                    sObject[] sObjects = new sObject[] { lineItem };

                    LimitInfo[] limitInfo;
                    SaveResult[] saveResult;

                    DebuggingInfo debugInfo = Client.update(Header, null, null, null, null, null, null, null, null, null, null, null, null,
                        sObjects, out limitInfo, out saveResult);

                    Logout();
                }


 
Alexey ZholobovAlexey Zholobov
Hi, I am experiencing the same issue. Did you find a solution?
Steven Murphy 6Steven Murphy 6
I've been away from this for awhile, so I don't remember exactly. It had to do with how I added the service reference. I think that I needed to go back and add it as a 2.0 web reference for compatibilty. After that the following code will work:
public void UpdateLineItem()
        {
            try
            {
                if(Login())
                {
                    string lineItemId = GetOpportunityLineItemId();

                    OpportunityLineItem lineItem = new OpportunityLineItem();
                    lineItem.Id = lineItemId;
                    lineItem.Description += "Gold Package";
                    lineItem.Quantity = 86;
                    lineItem.QuantitySpecified = true;

                    sObject[] sObjects = new sObject[] { lineItem };
                    SaveResult[] saveResult;

                    saveResult = Binding.update(sObjects);

                    Logout();
                }
            }
            catch (Exception e1)
            {
                ConsoleLog.ConsoleWriteLine(e1.Message);
                ConsoleLog.LogWriteLine(e1.StackTrace);
                Logout();
            }
        }