I wonder, what are the best practices I should apply when I need to integrate Salesforce with an external SOAP webservice?

First of all - Apex class names generated with wsdl2apex have names which cannot clearly describe their responsibility. Is it a correct approach to refactor classes to more developer friendly names?

Additionally which design pattern will be a good starting point to simplify complex webservice logic? Introducing the Facade design pattern - is it a correct way in that case?

1 Answer 1


My best practice here is to whenever possible use the REST/JSON API instead if one is available.

Why? Salesforce's wsdl2apex has a number of limitations - see e.g. Danial Ballinger's An alternative to Salesforces Wsdl2Apex for calling SOAP web services in Apex - that can leave you stuck with generated code that does not work.

When working with JSON, the Apex JSON Class is pretty good, and you are much less likely to get stuck. There is also this code generator JSON2Apex that works from an example of the JSON.

So generally best to look at both alternatives.

  • Yes. I know that REST will be better but SOAP endpoint is all I have. FUSE IT SFDC Explorer seems to be another tool to generate apex classes from wsdl but I need refactor them to be more developer friendly. Feb 20, 2022 at 10:37
  • Hi @gpoluch, OK. AFAIK the class names and property names are locked to the WSDL names so apart from perhaps the containing class name everything is locked down. You could put another layer of classes around the generated ones but if you do be sure they help more than they hinder.
    – Keith C
    Feb 20, 2022 at 10:47
  • You're right with that @Keith C. I noticed that there is also the possibility to use XmlStreamWriter class but I am not sure about maintainability that type of solution. Feb 20, 2022 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .