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
aezellaezell 

Dealing with XML returned from Web Service

The new callout functionality is really great. However, there seems to be a rather gaping hole.

Many web services return XML in their responses, yet, Apex seems to have no way to deal with this XML. There seems to be no variable type in which to store the XML and no methods for parsing that XML.

I must be missing something. My use case here is a callout to the Zipcode Info service at webservicex.net. It returns XML which contains information about that zipcode, including city and state.

I've generated the Apex class from the WSDL and it's compiled fine. What I can't seem to do is write any code that will compile because the return value from the class calling the service is always expected to be XML.

The WSDL location is here: http://www.webservicex.net/uszip.asmx?wsdl

I edited it to use only the SOAP ports and bindings. Would I be better off using one of the other bindings/ports?

Essentially, I'm just lost here finding out any details on consuming a third-party web service past the basic, and seemingly incomplete, examples in the Apex Language Reference.

Thanks for reading all that!
cheenathcheenath
I looked at the wsdl and it is using xsd:any. Web Service callout does not
support xsd:any yet.

Next release we are planning to support HTTP callout and an XML parser
in Apex. I think this will solve your problem.

Thanks,


aezellaezell
Thanks Cheenath. This brings me to a followup question.

Is there any support in Apex for REST-based web services?
cheenathcheenath
Not now, you have to wait till next release, sorry.
With HTTP callout you can callout to any http server
(including rest endpoints).


aezellaezell
I'm not sure I understand what you mean Cheenath.

What's the difference between HTTP Callouts and Webservice Callouts?
SuperfellSuperfell
HTTP callouts are for basic HTTP calls, you control the payload etc. (aka REST) WebService callouts are specifically for SOAP/WSDL based services.
aezellaezell
Thanks Simon!

Any chance you could point me to some documentation on that? I don't see it mentioned in the language reference or the cookbook.

These HTTP Callouts are available within an Apex class, right? What about inside an Apex trigger?

Like I said, if this is all documented somewhere, please point me that way. :)
cheenathcheenath
1. Callouts (both web service and http) are not allowed from triggers.
2. HTTP callout is not released (GA) yet.