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

Error parsing .Net 3.0 WCF wsdl from Apex Code

I login to developer, click Setup, Build, Code and then click Generate from WSDL.  I browse to our wsdl and then get an error.
The error I get is "Error: Failed to parse wsdl: Unknown element: import."  Does Apex support .Net 3.0 WCF services?


I'm not super-clear from your description where your error is coming from.  We do have an application using SalesForce's Web Services API with .NET 3.5, so my best guess is you can get it to work with 3.0.  We did have to work through a few issues, and I don't have detailed information on them, but most were minor. 

The one main thing you need is this.  In Visual Studio when you say "Add Service Reference", click on the "Advanced" button down on the bottom left.  Then click "Add Web Reference" down at the bottom under the Compatibility section. 

As I mentioned, there are still a few gotchas before you can get the examples to work, but you can get them to work with a few mods.  We've continued to discover minor issues and discrepancies with the API, but using the Compatibility mode was the big one!


Thank you for the reply. 

I am not using .Net to call web services but just the opposite.  The exact steps I take are outlined in my original email.  I am trying to get to call my .Net web services.


I think you need to use SVCUTIL.EXE to create a proxy class based on SForce's WSDL.  See

I am also trying to consume Sforce's outbound message via a .Net 3.0 web service using WCF.  I can get pass importing wsdl by using svcutil.exe to create a proxy class.  However during testing my web service reports the following error:

"The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)."

Looks like WCF expects a SOAP action specified, but Sforce's SOAP message doesn't have one?  Has anyone encountered this issue before?
Hey Ryan,

Can you attach your wsdl file? The simplest Hello World .NET 3.x web service wsdl works just fine (with a little tweaking unrelated to Unknown element).

Hi Ryan,

My mistake, I see you are using WCF instead of "web service". Not sure that we support that or not, but will find out from the API/APEX team.

So, WCF splits the wsdl in to different parts and uses imports and such. We currently don't support import or include.

We also don't support any WS-* specs. Because of these two reasons, it's best just to use the regular .NET asmx approach.



Thank you for the information.  Any idea when you will support WCF web services?


What in particular in WCF are you looking to use that ASMX doesn't give you ?

WCF dramatically simplifies the development of web services.  The purpose, as I understand it, is to separate out how a message travels and what security is required and many other items about a message from the code and put those types of items into a config file.  For example, using WCF if I want to send the data encrypted over the wire my code does not change a single bit; rather I can make that change in the config file. 

I have seen some web services developed that had hundreds of lines of code to be able to attach x.509 security certificates and such; whereas, with WCF that can all be done in a config file and your code never needs to change.


But none of those WS-* services that are config based are used in apex callouts.
Brad RileyBrad Riley

I have the same issue regarding WCF services integrating with Salesforce.  The difference is that my company have set up a complete infrastructure to handle all communications between applications using WCF.  Therefore it is a 'standard' that I have to adhere to.  If Salesforce can't consume WCF web services then I am simply stuck :(

Any idea if/when Salesforce will be able to consume WCF services?

We need WCF to work too, any advancements in the past year??

Hello - were you able to make wcf work with wsdl2apex ? if yes, could you please let me know what you did to resolve the issue. 


Thank you in advance




Hi Raghu_dev,

did you manage to get this sorted out. Seems SF doesnt support WSDL with imports in them.





Yes but with the workaround. We wrote java wrapper on top of the .net webservice which will allow us to import the wsdl into SFDC. Also, I started using http post to send the request and to get the response. Provided some sample code below



		  req.setHeader('content-type', 'text/xml; charset=utf-8');  
	      req.setHeader('SOAPAction', 'http://wcf42.Services/IPartySvc/GetContactsByPartyNoXml'); 
		  Http http = new Http();
		  SimpleXMLParser.ReturnObject xmlparserError = new SimpleXMLParser.ReturnObject();
		  SimpleXMLParser.ReturnObject[] xmlparserErrors = new SimpleXMLParser.ReturnObject[0];
		  //Send the request, and return a response 
		  System.debug('Request sent: ' + req.getBody());
		  HttpResponse resObj = new HttpResponse();
		  String response = '';




Hi Ragz,


May I know what the java wrapper is?


My understanding is that you built another java web service as a proxy.  


Everytime the methods call look like: ---> JAVA web Service ---> .net web service.  


then the response: .net web service -->Java Web Service -->


Please correct me if I am wrong.


Thanks in Advance





Yes. That is correct.

HI, After two more years from this last response I am wondering if anything new came out since then?
Is there a way to call WCF web service from Salesforce, even using a workaround?