+ Start a Discussion
engrDaveengrDave 

I have searched the API docs and discussion boards and have not found any info about how to get to the SforceService or where it comes from, so I am starting a new post for this.

 

I am using VS2008, but target the .NET Compact Framework 2.0 for a CE 5.0 device. I generated a Partner WSDL (Which includes the SforceService endpoint def.). In VS2008, I added a Web Reference (not a WCF Service Reference!) and found the service description using the URL:

https://login.salesforce.com/?ec=302&startURL=%2Fservices%2Fwsdl%2Fclass%2FserviceName

(which looked successful).

 

I get the correct namespace added to my project with the proxy class for the service. When I try to set up the SOAP binding, I have no access to SforceService and cannot see it in the Object Browser. Is there something (i.e., an SDK) that I need to install to get this, or should it show up automatically from the service description while adding the Web Reference?

 

Please help! TIA, Dave

Best Answer chosen by Admin (Salesforce Developers) 
PaulAtInformzPaulAtInformz

I have been using the local WSDL file method. To get the local WSDL, I had to open the WSDL link and then view source. I copied everything there and pasted it into a text file and changed the extension to wsdl. Then in VS I added a web service reference and pointed it at file://c:\folder\path\to\file\wsdlFile.wsdl. That imported the whole thing correctly and you should then have access to the SoapClient. I'm sure smarter people than myself could tell you an easier way to do this, but that's what worked for me. 

igressigress 
Hi ,
Since Salesforce Disabling TLS 1.0 Encryption, I am using .NET Framework 4.0 Webclient class to connect to salesforce. 

var _webClient=new WebClient();
var content = new System.Collections.Specialized.NameValueCollection
            {
                {"grant_type", "password"},
                {"client_id", clientId},
                {"client_secret", clientSecret},
                {"username", username},
                {"password", password}
            };
var responseBytes = _webClient.UploadValues(tokenRequestEndpointUrl, "POST", content);
var responseBody = Encoding.UTF8.GetString(responseBytes);

I know that System.Net.ServicePointManager.SecurityProtocol (https://msdn.microsoft.com/en-us/library/system.net.securityprotocoltype(v=vs.100).aspx)supports Tls (which is default choice) . But as you look at the link it says it is TLS1.0 protocol. How do I specify TLS1.1 and higher.

I cannot upgrade my existing solution to .NET4.5 since it is a huge undertaking. Is upgrading to .NET4.5 the only way because I see System.Net.ServicePointManager.SecurityProtocol (https://msdn.microsoft.com/en-us/library/system.net.securityprotocoltype(v=vs.110).aspx) supports TLS1.1 and 1.2.

Thanks

Related post: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BMX0IAO
Best Answer chosen by igress
Daniel BallingerDaniel Ballinger
I don't believe there is a native way to add TLS1.1 or 1.2 support to the .NET 4.0 framework. At least not where it would be less effort than upgrading to .NET 4.5+.

There are a couple of options for .NET 4.0 listed in Are there .NET implementation of TLS 1.2? (http://stackoverflow.com/q/4137106/54026). You would be doing COM to schannel.dll (http://msdn.microsoft.com/en-us/library/aa380516%28v=VS.85%29.aspx) or using a third party product (http://stackoverflow.com/a/4138158/54026).

​In my opinion, upgrading the .NET framework would be less error prone than those approaches.
tyler young 35tyler young 35 

I'm using the Salesforce.Force NuGet package to upsert records, and if I don't include the Address property on the Lead, it works just fine. When I include Address, it gives the following error (in JSON):

[{"message":"Cannot deserialize instance of Address from VALUE_STRING value IROQUOIS at [line:1, column:21]","errorCode":"JSON_PARSER_ERROR"}]

The relevant JSON sent to the server is:

{"Address":
    {
        "City":"IROQUOIS",
        "Country":"Canada",
        "CountryCode":"CAN",
        "PostalCode":"K0E 1K0",
        "State":"ONTARIO",
        "StateCode":"ON",
        "Street":"SENSITIVE_DATA_HERE"
    },
"Company":"SENSITIVE_DATA_HERE",
"Description":"SENSITIVE_DATA_HERE",
"Email":"SENSITIVE_DATA_HERE"....}


Any ideas on why it's having trouble deserializing the address?
 
Best Answer chosen by tyler young 35
Daniel BallingerDaniel Ballinger
Oddly, the capitalization of the JSON appears to impact how it is deserialized. If I send in the following JSON:
 
{"Address": {
        "City": "Nelson",
        "Country": "New Zealand",
        "CountryCode": null,
        "PostalCode": "7011",
        "State": "Nelson",
        "StateCode": null,
        "Street": "7 Forests Rd\r\nStoke"
    },
 "Company":"TestLeadCompany2",
"Description":"SENSITIVE_DATA_HERE",
"Email":"daniel.ballinger@example.com",
 "LastName": "Ballinger"}

I get the response:
[
    {
        "message": "Cannot deserialize instance of Address from VALUE_STRING value Nelson at [line:2, column:18]",
        "errorCode": "JSON_PARSER_ERROR"
    }
]
 
 
If the casing of the address members is converted to lower case, the response changes:
{"Address": {
        "city": "Nelson",
        "country": "New Zealand",
        "countryCode": null,
        "postalCode": "7011",
        "state": "Nelson",
        "stateCode": null,
        "street": "7 Forests Rd\r\nStoke"
    },
 "Company":"TestLeadCompany2",
"Description":"SENSITIVE_DATA_HERE",
"Email":"daniel.ballinger@example.com",
 "LastName": "Ballinger"}
[
    {
        "message": "Unable to create/update fields: Address. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",
        "errorCode": "INVALID_FIELD_FOR_INSERT_UPDATE",
        "fields": [
            "Address"
        ]
    }
]
Instead you need to send in the Address data using the direct fields on the Lead.
{
  "City": "Nelson",
  "Country": "New Zealand",
  "PostalCode": "7011",
  "State": "Nelson",
  "Street": "7 Forests Rd\r\nStoke",
    
  "Company":"TestLeadCompany2",
  "Description":"SENSITIVE_DATA_HERE",
  "Email":"daniel.ballinger@example.com",
  "LastName": "Ballinger"
}


Gives:

{
    "id": "00Qo000000Hd2IxEAJ",
    "success": true,
    "errors": []
}

Does the Salesforce Toolkit (https://github.com/developerforce/Force.com-Toolkit-for-NET) provide directly properties that you can set on the Lead for City, Country, State, etc..?

Devender Kumar 13Devender Kumar 13 
Salesforce is going to disable SSL 3.0 encription on 7th November for all the sandbox instances and later for production instances.
In sandbox environment, my .Net client application using OAuth 2.0 Web Server flow and salesforce APIs to communicate with salesforce.  How could I verify that my API integration is using SSL 3.0 encription and how could I change it to TLS 1.0? Where could I found these settings?

Many thanks in advance.
Best Answer chosen by Sonam (Salesforce Developers) 
Devender Kumar 13Devender Kumar 13
We got another useful link addressing this issue:

http://salesforce.stackexchange.com/questions/54960/ensuring-my-application-complies-with-ssl3-0-being-disabled

 
Nicole NammourNicole Nammour 
Hello,

Is there a way to get custom labels (FullName and values) through metadata api?
Currently i can get only FullName, i can't retrieve the values.

Thanks,

Nicole
Best Answer chosen by Nicole Nammour
Maria AssalMaria Assal
Hi Nicole,

You can use the Metadat API method listMetadata specifying the type as "CustomLabel" to get the fullName of the label, and then use readMetadata passing the fullName as parameter to retrieve its value.

Good Luck

GobbledigookGobbledigook 

Hey all,

 

I'm having a problem where I need to dynamically update a picklist through a web service from an ERP system to Salesforce, and so I've started working on it, using C#.  The list will change depending on business practices throughout and will be "pushed" from the ERP to Salesforce nightly. 

 

So I was able to create the picklist values through the Web Service, as well as Update the picklist values using the metadata API.  The problem I'm running into now is deleting the values WITHOUT deleting the entire picklist itself. 

 

I've tried using delete but that will get rid of the entire picklist, and I only want to get rid of a few values at a time.  Any thoughts or examples that might help out? 

Best Answer chosen by Admin (Salesforce Developers) 
ShwetaSShwetaS

Hi,

 

We cannot delete the picklist values that has been saved to our organisation, since data rows might exist that would need to be interactively remapped.

 

Please refer the below link for more reference.

http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_picklist.htm


Shweta
Salesforce Developer Support

If my answer solved your question, please mark it solved so I can help as many community members as possible!

Best Answer chosen by Mickey Patel
Mickey PatelMickey Patel
I resloved the isuue at the end of this mething I had to to test url. so instead of this
await auth.UsernamePasswordAsync("Client ID got from Sandbox , "Consumer key got from Sanbox" , "mickey_patel@nwtc.com.ntcdev", "SandBox password");

I had to do this.

await auth.UsernamePasswordAsync("Client ID got from Sandbox , "Consumer key got from Sanbox" , "mickey_patel@nwtc.com.ntcdev", "SandBox password", "test url");

in production you do not need to do that.
sd2008sd2008 
I query two fields
 

qr = binding.query("select TPAID__c, AssocID__c from Account where AssocID__c = 1234")

 

and the query runs fine, but how to display the queried data?

dim acct as enterprise.Account

acct = CType(qr.records(0), Enterprise.Account)

acct.TPAID does not exist

 
Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
acct.tpaid__c

if that field doesn't exist in the account class, then it was added in salesforce after you downloaded the WSDL, download a current enterprise WSDL and do an update web reference.
pablorpablor 

Hi

 

We are trying to use web service callouts and we are nearly there!

 

The web service callouts work, but only on our client's server (Running Windows 2008 and IIS6)

http://webservices.wlrstore.com/aiWebAdServerDemo/test1getpost.asmx 

 

But it dows NOT work on our own server (a virtual sever at Fasthosts, running Windows 2008 R2 and IIS7.5)

http://salesforce.alpha-index.co.uk/packageservice/helloworld.asmx

 

Both these web services have the HelloWorld method, and they work fine when we call them from a .Net page.

 

But in Salesforce the first URL works fine, but we get this error when we call the web service on our server:

 

System.CalloutException: IO Exception: Read timed out

 

 

 And if we try to execute like anonymous in Force IDE, we find this error:

 

(59124000)|CALLOUT_REQUEST|[28]|<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><sayHelloWorld xmlns="http://salesforce.alpha-index.co.uk/packageservice/" /></env:Body></env:Envelope>
(59194000)|CALLOUT_REQUEST|[28]|sayHelloWorld_element:[apex_schema_type_info=(http://salesforce.alpha-index.co.uk/packageservice/, true, false), field_order_type_info=()]::SFDC_STACK_DEPTH=1 SOAPAction="http://salesforce.alpha-index.co.uk/packageservice/sayHelloWorld" User-Agent=SFDC-Callout/27.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8 
(10060111000)|EXCEPTION_THROWN|[28]|System.CalloutException: IO Exception: Read timed out
(10060449000)|METHOD_EXIT|[2]|01pd0000002I2L2|AlphaIndex.alphaIndexCoUkSample.HelloWorldSoap.sayHelloWorld()
(10060568000)|FATAL_ERROR|System.CalloutException: IO Exception: Read timed out

 

 

Does anyone know if there is an issue with Salesforce and IIS7 web services?

You don't need a certificate to use web services with Salesforce do you?

Could it be a firewall port setting?

Anybody have any other ideas?

 

Please help!!

 

Thank you in advance.

Pablo

Best Answer chosen by Admin (Salesforce Developers) 
pablorpablor

Hi

 

After trying months and try everything that I could think... I have the solution.

 

The antivirus has a option which keeps out to any email in our system. For some reason, the antivirus believes that the actions, like POST, are emails.

So when we remove this option from our server, all the actions from salesforce began to work.

 

I hope that this can help anyone who has this problem.

 

Pablo 

DalianhankDalianhank 

I was using REST API to create a new record for object "Task" , but keep getting error {"The remote server returned an error: (400) Bad Request."}. I can update(insert) a new value for object "Task" field by using method "PATCH", but can use "POST' to create a entire new record. The code is following:

 

//Task Object
public class sfTask
{
public string AccountId { get; set; }
public string Description { get; set; }
public string Subject { get; set; }
public string OwnerId { get; set; }
public string WhoId { get; set; }
public string LastModifiedById { get; set; }
public string CreatedById { get; set; }
public string Status { get; set; }
public string Priority { get; set; }
public bool IsReminderSet { get; set; }

}

public string sfTaskCreat(string Id, string AccountId, string installapptask)
{
var sftaskupdate = new SalesForceREST();
sftaskupdate.GetTokenUsernamePassword();


var uri = sftaskupdate.token.instance_url + "/services/data/v24.0/sobjects/Task/" ;

var task = new sfTask();

task.Subject = installapptask;
task.WhoId = Id;
task.AccountId = AccountId;
task.Description = "this is a ipad app download testing";
task.OwnerId = "005XXXXXXXXXXXAG";
task.CreatedById = "005XXXXXXXXXXAG";
task.LastModifiedById = "005XXXXXXXXXAG";
task.Priority = "Normal";
task.Status = "Completed";
task.IsReminderSet = false;

var ser = new JavaScriptSerializer();
var body = ser.Serialize(task);


System.Net.WebRequest req = System.Net.WebRequest.Create(uri);
req.Headers.Add("Authorization: Bearer " + sftaskupdate.token.access_token);
req.ContentType = "application/json";
req.Method = "POST";

// Add parameters to post
byte[] data = System.Text.Encoding.ASCII.GetBytes(body);
req.ContentLength = data.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(data, 0, data.Length);
os.Close();

// Do the post and get the response.
WebResponse resp;

try
{
resp = req.GetResponse();
}
catch (WebException ex)
{
resp = ex.Response;
}

if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}

 

Thanks for any advice!

Best Answer chosen by Admin (Salesforce Developers) 
DalianhankDalianhank

I figured it out. Basically on my code using some reference field (Contains an Id Value) that points to unique record(usually the parent record) on another object. When you try to create a record and even you provide an correct value for those reference field (for example: AccountId, OwnerId etc...) ,you will get an 400 error. After I revise the code as follows, and it works fine now.

 

//Task Object
public class sfdcTask
{
 
public string WhoId { get; set; }
//public string ActivityDate { get; set; }
public string Description { get; set; }
public string Subject { get; set; }
public string Status { get; set; }
public string Priority { get; set; }
 
}
public string sfTaskCreat(string whoId, string installapptask)
{
var sftaskcreate = new SalesForceREST();
sftaskcreate.GetTokenUsernamePassword();

var uri = sftaskcreate.token.instance_url + "/services/data/v24.0/sobjects/Task/";
var task = new sfdcTask();

task.Subject = installapptask;
task.WhoId = whoId;

task.Description = "this is a ipad app download testing";
task.Priority = "Normal";
task.Status = "Completed";

var ser = new JavaScriptSerializer();
var body = ser.Serialize(task);
 
System.Net.WebRequest req = System.Net.WebRequest.Create(uri);
req.Headers.Add("Authorization: Bearer " + sftaskcreate.token.access_token);
req.ContentType = "application/json";
req.Method = "POST";
// Add parameters to post
byte[] data = System.Text.Encoding.ASCII.GetBytes(body);
req.ContentLength = data.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(data, 0, data.Length);
os.Close();
// Do the post and get the response.
WebResponse resp;
try
{
resp = req.GetResponse();
}
catch (WebException ex)
{
resp = ex.Response;
}
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}

 

 

There is some instruction about "Reference Field Type"

Reference Field Type

A reference field contains an Id value that points to a unique record (usually the parent record) on another object. This is analogous to the concept of a foreign key in relational databases. The name of a reference field ends, by convention, with the letters Id (such as CaseId orOpportunityId). For example, in the OpportunityCompetitor object, the OpportunityId field is a reference field that points to the Opportunity object. It contains an ID value that uniquely identifies an Opportunity record.

In some cases, an object can refer to another object of its same type. For example, an Account can have a parent link that points to another Account.

The Event and Task objects both have WhoId and WhatId cross-reference ID fields. Each of these cross-reference fields can point to one of several other objects. The WhoId field can point to a Contact or Lead, and the WhatId field can point to an Account, Opportunity, Campaign, orCase. In addition, if the WhoId field refers to a Lead, then the WhatId field must be empty.

You can describe and query each cross-referenced object. When you query a cross-reference ID field, it returns an object ID of the appropriate type. You can then query that ID to get additional information about the object, using the ID in the id field for that query.

The cross-reference ID field value is either:

  • a valid record in your organization, or
  • an empty value, which indicates an empty reference

The cross-reference ID field value, if non-null, is guaranteed to be an object in your organization. However, it is not guaranteed that you can query that object. Users with the “View All Data” permission can always query that object. Other users may be restricted from viewing or editing the referenced object.

When specifying a value for a cross-reference ID field in a create() or update() call, the value must be a valid value of type ID, and the user must have appropriate access to that object. The exact requirements vary from field to field.

 

More detail you can find in: http://www.salesforce.com/us/developer/docs/api/Content/field_types.htm