Salesforce - How to make an XML Listener for an external System

Viewed 12

I've been tasked with connecting my salesforce org to the system of one of our vendors. On my end, I'm supposed to take data from one of our custom objects, put it in XML format and send it to their endpoint. This part was easy to do.

However I don't know how to do the other half. How do I build something to listen for and take in their XML responses?

All the documentation I have read about Connected Apps, SOAP and REST API and Platform events seems like it is geared toward connecting internal client side apps with Salesforce. But how do i help an external company send data into our org in a limited way?

I'm only a junior Apex Dev so I don't really know anything about integrations or APIs yet.

Thanks.

1 Answers

You might be doing it wrong.

If your scenario is "send request - wait for response" and the vendor has exposed a SOAP wsdl file - you can consume that WSDL file and generate so-called stubs of methods. "consuming" means generating a bunch of classes and methods in your preferred language (Apex, but same rule applies to Python, C#, PHP). Meaning you work with "normal" apex code, set field values etc. And only at the end you call "now send it" method that will turn that into XML and deal with all stupid little things (proper date and datetime formatting, escaping special characters like < to &lt; etc). This is much better than hand-crafting the XML payload and manually doing HTTP POST

Salesforce callout done like that can wait for up to 2 minutes for response. SOAP integrations are bit old, you may have to read up a bit but at least now you know what to search for.

If the vendor's service is unlikely to return in 2 minutes (but they will eventually, we're still in the "request from sf - response from vendor" mode!) the generated code should contain alternative way of calling that with a Continuation.


If this is not a "send request - wait for response", if the vendor needs ability to push data to you anytime, whether they had requests or not - you reverse the process. Vendor will need a sysadmin-like user to login to salesforce. If they prefer SOAP - you can export the WSDL file from setup and they'll consume it on their end. This will let them create/read/update/delete data in salesforce (the Profile & Permission Sets on the user you'll give them will dictate what exactly they can do). If they don't want raw access to SF API, if the message from them is complex and you want to process it a bit (and say update 5 different objects in one go) - you might want to write bit of apex and expose it as SOAP endpoint using webservice keyword.

Related