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
SurpriseSurprise 

Basic Xml in apex

Hi All,

 

If I write webservices in salesforce and comsumed by somebody else then that person will parse xml reponse before doing anyhting else.Is that correct?

 

While writing webservcie in salesorce.Do I need to write any XMl anywhere or its get's generated in the background by the force.com platform and I need not worry about it.?I should simply create webservcie in salesorce and that's it.

 

Can somebody please answer as early as possible?

 

 

Thanks,

Surprise

sfdcfoxsfdcfox
When you create a webservice class, it generates a WSDL. In practical terms, that means that anyone wishing to consume your webserivce simply needs to import the WSDL and operate on the object(s) that are generated as a result of the import. They will also need a login WSDL, such as the partner or enterprise WSDL. Example:

SforceClient client = new SforceClient()
LoginResult login = client.login(username,password);
if(login.sessionId) {
MyWebServiceClient myWS = new MyWebServiceClient();
myWS.sessionId = login.sessionId;
String result = myWS.doSomething(param1,param2);
}

Of course, this is simplified, but hopefully you'll get the basics from this. The language being used will automatically convert the function calls used to the appropriate XML and SOAP function calls, post the request to the server, and receive a response. The code above is illustrative and not meant to be taken verbatim.

No XML ever needs to be written by the developer so long as their IDE or language supports SOAP.
SurpriseSurprise

Thanks Sfdcfox for answering my question,

 

Now I do not have to worry about Xml since Apex has in built support for XML.

 

Do we need to parse reponse as a result of consuming web services or we can smply insert reponse in salesforce?

 

Is the reponse always in the form of XML?.

 

I will develop some webservice in salesforce.I would like to consume from outside.Do u know some tool which I can use to consume and see its output.   I do not want to write java or C# to do such testing.

 

Thanks,

Surprise

 

 

 

 

 

 

 

 

 

sfdcfoxsfdcfox
SOAP is a transport encoding, and won't be "directly" exposed when using WSDLs in a programming environment. From a developer perspective, the response will be a native object in the language, not an XML file that needs parsing.

For testing, you could try using some sort of generic SOAP client, such as SoapUi or The SOAP tools available in Microsoft Visual Studio 2008 (depending on what you have available to you). You don't necessarily need to write up a fully compiled program just to test the service. There are also some web-based tools for testing SOAP messages. These sorts of tools will most likely show the raw response and a parsed view of the response (e.g. a tree view that shows the response elements).