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
Michael Zink 8Michael Zink 8 

Create custom apex class to call out to WSDL API thats using rpc style

Hello.

Just starting out in salesforce and wanting to do a proof of concept.
This involves connecting to an external wsdl api that is using style=rpc.

I can see the WSDL2Apex doesnt support rpc.

So I am trying to figure out how to create a custom apex class that i can connect to the api and pass in the credentials and paramaters.

I have managed to connect to this api and run tests using soap ui software, but not sure how to make this happen in a apex class.

If anyone has any suggestions that would be great.
Thanks.
Best Answer chosen by Michael Zink 8
AbhishekAbhishek (Salesforce Developers) 
Hi Michael,

One option would be to craft the raw HttpRequest(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm)

yourself and then parse the response.
A tool like SoapUI(https://www.soapui.org/)  would be really useful here. You could use it to generate sample requests and responses. Then you manually write the Apex to make the same POST requests with your parameters and handle the response.
The XmlDom class(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_xml_dom.htm) will be useful for both reading and writing the required XML.

The above is just a suggestion.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.

All Answers

AbhishekAbhishek (Salesforce Developers) 
Hi Michael,

One option would be to craft the raw HttpRequest(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_httprequest.htm)

yourself and then parse the response.
A tool like SoapUI(https://www.soapui.org/)  would be really useful here. You could use it to generate sample requests and responses. Then you manually write the Apex to make the same POST requests with your parameters and handle the response.
The XmlDom class(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_xml_dom.htm) will be useful for both reading and writing the required XML.

The above is just a suggestion.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
This was selected as the best answer
Michael Zink 8Michael Zink 8
Thanks Abhishek,

I managed to get a basic version of the HttpRequest going for demostration purposes.

And great suggestion about using soapui to generate sample requests.

Then after talking with parties involved we decided that would be best to build out new api's just for salesforce to connect with so we can then just use the WSDL2Apex :D

One again thanks for reply greatly appreciated.

Regards, Michael.