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
SalesRedSalesRed 

How to Return a Constructed SOAP Body instead of Salesforce generated SOAP Body from a Webservice

Hi,

 

I wish to have webservice functions which when called I will create a SOAP body which I then return in my response.  If I set the return type to String for my webservice function the stting gets included as CData in a <result> element.

 

E.G.

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/TestSOAPWebserviceFromSites">
<soapenv:Body>
<GetMsgRQResponse>
<result><![CDATA[<soapenv:Body><GetMsgRS><result>Success: Name=My Test</result></GetMsgRS></soapenv:Body>]]></result>
</GetMsgRQResponse>
</soapenv:Body>
</soapenv:Envelope>

 

If I wish to override the SOAP Body generated by Salesforce and instead make it my own generated SOAP body what is the return type I need to use for my function?

 

Thanks in advance for any help.

 

 

rforce2rforce2

Hi @SalesRed,

 

I also have to return an XML in the response.

 

According to the Apex Web Services and Callouts documentation, salesforce supports the token datatype of WSDL, which seems to be the most compatible datatype for CDATA.

 

Unfortunately, I didn't find find any apex datatype to be returned as token.

 

The most compatible datatype I found was Blob, it results as xsd:base64Binary, which can be decoded by the consumer.

 

SalesRedSalesRed

Hi