+ Start a Discussion
Keyur PatelKeyur Patel 

How can we call Salesforce webservice in .Net C#?

Hello,

 

We are trying to dynamically invoke salesforce webservice without adding webreference in C#.Net. Our requirement is generate proxy  based on salesforce wsdl and return method name, service name and out put automatically.

 

I am expecting same like in following URL : http://www.crowsprogramming.com/archives/66

 

We are passing following web request in c#. Net code. 

====================================================

HttpWebRequest client = (HttpWebRequest)HttpWebRequest.Create("https://servername/services/wsdl/class/WebServiceName" + "?wsdl");
client.Credentials = new NetworkCredential("xyz@company.com", "test1uHN46qCxXomWqfRcEupLW9cg");
client.Method = "POST";

//client.ContentType = "application/x-www-form-urlencoded";
client.Headers.Add("Authorization" , "Basic " + loginResult.sessionId);
client.Headers.Add("SOAPAction", "");
client.ContentType = "text/xml;charset=\"utf-8\"";

 

HttpWebResponse wres = (HttpWebResponse)client.GetResponse();

XmlTextReader xmlreader = new XmlTextReader(wres.GetResponseStream());

serviceDescription = ServiceDescription.Read(xmlreader);

====================================================

We are getting following errors.

 

An error has occurred while opening external DTD 'http://www.w3.org/TR/html4/loose.dtd':  The remote server returned an error: (500) Internal Server Error."}

 

How can i resolve this error?

Wade WegnerWade Wegner
Do you need to use SOAP? If not you can use the .NET Toolkit for Force.com. Details here: http://blogs.developerforce.com/developer-relations/2014/01/announcing-the-salesforce-toolkits-for-net.html
Keyur PatelKeyur Patel
I have resolved this issue. Thanks for sharing salesforce toolkits link. It might helpful for me in future development in .Net with salesforce.
Ahmad HirbawiAhmad Hirbawi
@Keyur Patel, can you please share with the community how did you resolve this issue? Thanks.