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
engrDaveengrDave 

How do I get to SforceService?

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. 

All Answers

SuperfellSuperfell

Add Web Reference should generate the SforceService class. Look at the c# code generated from the WSDL.

SuperfellSuperfell

Also, download and store a local copy of the WSDL and use that, don't try and use the URL to the WSDL in add web reference, it won't work. See the getting started guide in the Web Services API Docs.

engrDaveengrDave

Thanks for your replies, Simon.

 

I tried a local copy of the Partner WSDL, but VS2008 complains about the comments...Then after removing all of those, it says the document is not recognized as a known document type, with only a partial error message from 'DISCO Document' report. As a result, I am unable to finish adding the reference.

 

Thanks,

Dave

SuperfellSuperfell

Make sure the local file you have is really the WSDL file.

engrDaveengrDave

The Add Web Reference dialog shows the content in the WSDL and it looks to be correct. The file path is also correct.

 

Way at the bottom of the display window there is an error saying that the XML page cannot be displayed using XSL style sheet...with a complaint about the <xsd:complexType name="PackageVersion"> element. Also, if I open the WSDL in VS, it shows errors related to "xsd" namespace refs. Is there some reference that I need in my project, or??

 

Thanks,

Dave

PaulAtInformzPaulAtInformz

I've seen your issue when using VS 2008 or VS 2010. There is no SforceService object created when you import any of the WSDLs. There is a SoapClient object that has all the methods that are referenced in the tutorials. I think that might be the object you should be using.

engrDaveengrDave

Thanks for the reply, PaulAtInformz.

 

Have you seen this using the local WSDL file method, or the URL approach? I am unable to get a local WSDL file to work at all. The WSDL URL claims success, and then allows me to add the reference. When I do that, I don't see a SoapClient object in the Object Browser thoough. Do you recall where I might find the SoapClient?

 

Thanks,

Dave

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. 

This was selected as the best answer
engrDaveengrDave

PaulAtInformz,

 

Thanks! Your suggestion worked, but instead of getting the SoapClient, I actually got the SforceService! Kudos for figuring this out.

 

The documentation on this area of development is not very clear...It just kind of says "Do this, this, and this, and it works.". Problem is, it doesn't "just work".

 

For anyone else running into similar issues, it was critical to "view page source" and copy/paste that into the local file (NOT the XML displayed in the browser page). The exact behavior in Visual Studio is different if you target a different .NET, etc. But once you have the SforceService definition in your project, you can get the login() call to work and away you go. Just watch out for the URL and session ID issues after the login() call is made.

 

Thanks again,

Dave

 

 

seamus7seamus7

I'm using VS 2010 and I got as far as generating the Service with wsdl before I found this discussion thread...

But I can't get th login() to work. Can someone paste some example code?

 

tia

 

seamus

SuperfellSuperfell

There's samples in the docs. Make sure you did add web reference, and not add service reference.

stalbertstalbert

In the era of WCF, I don't recommend anyone do "Add web reference", ever.

 

 

 

 

SimplySfdcSimplySfdc

REST API?

stalbertstalbert

WCF supports REST, if I understand your reply correctly.

 

http://msdn.microsoft.com/en-us/netframework/dd547388

 

and  in .NET 4 REST support is even better

http://www.dotnetcurry.com/ShowArticle.aspx?ID=399

 

 

I can see no reason one would not use WCF for any new web service development on the .NET platform. It's vastly superior to the technologies that preceded it.

fitzyfitzy

I think I got this working in .net 4.0 / C# by adding an old school web reference instead of service reference.  right click project - add service reference - point to downloaded - source saved wsdl - click advanced - there's an option for old school web reference instead of service reference.

hpandeyhpandey

Based on your suggestion I get this error though

 

The  namespace 'Salesforce.sforce' already contains a definition for 'ExceptionCode'17C:\Users\hpandey\Desktop\SalesforceConnector\Salesforce\Service References\sforce\Reference.cs844Walkthrough

neeraj_cloudneeraj_cloud

HI ,

Can you please explane a bit more that how did you get sforceservice .I have to consume salesforce webservice in silverlight client but cant add webreference , only service reference can be used ,  and service reference dont give sforceservice clss , it gives only soapclient class object 

 

Please help .it is urgent

 

atila1.3934285468997732E12atila1.3934285468997732E12
I had the same problem. When I tried import wsdl file, the SforceService wasn't created. But the problem was that I wasn't using the correct tool on Visual Studio. To create this SforceService class, on your .net project, you should:
- "Add Service Reference";
- Click on "Advanced" button;
- Click on "Add Web Reference" button;

Now you can add you wsdl file or wsdl url and the SforceService class will be created.
Jeff DeMuthJeff DeMuth
From Setup, click Develop then click API then Right Click Generate Enterprise WSDL and select Save Link as.  This prepopulated the name as Enterprise.wsdl 
Claudio Ungaro 5Claudio Ungaro 5
Good day,
I have downloaded the lates available version of Enterprise.wsdl, and had problems since the beginning. the ()() first and now the SforceService no available.
I have checked and the SforceService is present in the original XLM file downloaded but it is absent from the "reference.vb" file.
I have downloaded the set of VB samples and the attached references that works like a charms, only problem is that this wercsion is dated 2007!!!
I have checked the correct references, imprts and all the stuff, but still i have not the binding with SforceService.
Anyone can help?
Thank you in advance
Mekbeb WorkuMekbeb Worku
Here is a quick way for Visual Studio 2015. download the enterprise WSDL. then rename the extention to (.wsdl). then create a console application. and create a reference. When you create a reference, use the Service Reference and quickly go to the Advacned option. From the Advanced option you will find a way to add web reference (Add Web Reference). Once you get there, type the directory where you stored the WSDL file together with the file itself. click the arrow and in the box at the right side, name your namespace (i called sforce). and then click "Add Reference" below it. that will create all the classes you need
shirleyxiaoliqin Qinshirleyxiaoliqin Qin
To Mekbeb Worku:
The method you provided is correct, but sforceService cannot be instantiate it, when execute these 2 lines: SforceService sf = null; sf = new SforceService(); then get following errors: 
ex    {
"Unable to generate a temporary class (result=1).\r\n
error CS0030: Cannot convert type '
eForm.salesforcewebref.ListViewRecordColumn[]' to '
eForm.salesforcewebref.ListViewRecordColumn

'\r\nerror CS0030: Cannot convert type '

eForm.salesforcewebref.ListViewRecordColumn[]' to '
eForm.salesforcewebref.ListViewRecordColumn
'\r\nerror CS0029: Cannot implicitly convert type '

eForm.salesforcewebref.ListViewRecordColumn' to '
eForm.salesforcewebref.ListViewRecordColumn[]

'\r\nerror CS0029: Cannot implicitly convert type '
eForm.salesforcewebref.ListViewRecordColumn' to '
eForm.salesforcewebref.ListViewRecordColumn[]

Please help to see what is going on?

Shirley Qin
Terence WilsonTerence Wilson
I am writing a c# client for the first time to connect to the SFDC via the SOAP api  and I am been trying to login in using partner.LoginResult result =
loginClient.login(
null, //LoginScopeHeader
null, //calloptions
sfdcUserName,
loginPassword);  and getting the same exception as shirleyxiaoliqin Qin in the above post.   Any advice on what is going on .  I am using VS 2015 community edition
Terence WilsonTerence Wilson
So the issue is a sympton of this posted issue here https://help.salesforce.com/HTViewSolution?id=000205824&language=en_US  which has not yet been resolved:  The workaround can be found here https://developer.salesforce.com/forums?id=906F0000000AiPEIA0
Shriyal PadteShriyal Padte
I got VS 2015 (update-3) Now I am getting "Method SforceService.executeListView can not be reflected." So far I have edit [][], added tmp and refreshed/updated web-reference. Looks like this is going on for at least 2 years.
Shriyal PadteShriyal Padte
Edit: I have used @Terence Wilson's link https://developer.salesforce.com/forums?id=906F0000000AiPEIA0
for workaround.

In that edit [][], I made mistake and removed totally, it has to be just changed to [] (from 2 dimensional array to 1 dimensional). So far I have had these issues:

1. If it was not web-reference (but service reference), SforceService object is not generated. 
2. If the [][] in 2 places of reference.cs is not replaced by [] => there is runtime error : Unable to generate a temporary class (result=1)...
3. If the [][] is removed totally, then you will get : Method SforceService.executeListView can not be reflected.
 
Virendra Sharma 2Virendra Sharma 2

Thanks atila1.3934285468997732E12
It's work for me. Got SforceService after use this method.

David Henry 13David Henry 13
Although using Web Reference is discouraged by several people, it is the only way I could get their API to work like their sample code.  Without using WebReference, I was unable to access the SforceService object and had to use SoapClient instead.  Using Soap client made methods require many more parameters than what were shown in sample code.

For instance, when I use WebRefence and access SforceService, the "query" method is defined like this:
public QueryResult query(string queryString)

When I don't use Add WebRefrence and use SoapClient, the query method is defined like this:
public API.SalesforceReference.LimitInfo[] query(API.SalesforceReference.SessionHeader SessionHeader, API.SalesforceReference.QueryOptions QueryOptions, API.SalesforceReference.MruHeader MruHeader, API.SalesforceReference.PackageVersion[] PackageVersionHeader, string queryString, out API.SalesforceReference.QueryResult result)

The first version is obviously simpler, and matches their sample code.  So I'm using Add WebReference until this is cleared up.

 
Area SistemasArea Sistemas
Hello everyone, I am worked with VS2008 and Enterprise WSDL. I work fine, but when I compile the code, VS 2008 freeze. This only happen with WSDL Enterprise. Some one have the same issue?
THX