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
ccoltccolt 

XML-RPC Callout

Hi,

 

i want to call a function over XML-RPC.

I read the thread http://th3silverlining.com/2009/10/25/flickr-jquery-force-com-awesome5-part-1/#more-348 , but it didn´t work.

 

simple call (is dynamic on more than one server, but on each it´s a isAlive function):

 

 

public String isAliveMSG { get; set; }

    public PageReference XMLRCP_isAlive(String URL) {
    
        Httprequest request = new HttpRequest();
        request.setMethod('POST');
        request.setEndpoint(URL);

        String XML = '<methodCall><methodName>isAlive</methodName></methodCall>';
        request.setBody(XML);
        
        Http http = new Http();
        HttpResponse response = http.send(request);
        
        
        isAliveMSG = response.getBody();
        
        return null;
    }

 isAliveMSG is a Textarea.

the function isAlive has no parameters and the response is XML with true or false.

 

My response is

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
  <value>
    <struct>
      <member>
        <name>faultCode</name>
        <value><int>105</int></value>
      </member>
      <member>
        <name>faultString</name>
        <value><string>XML error: Invalid document end at line 1</string></value>
      </member>
    </struct>
  </value>
</fault>
</methodResponse>

 

 

From .NET (with XML-RPC.NET) or an online XML-RPC debuggers it call true back.

 

 

Can somebody help me ?

 

thanks

Best Answer chosen by Admin (Salesforce Developers) 
ccoltccolt

Hi,

 

thanks a lot SimonF.

 

 

request.setHeader('Content-Type', 'text/xml');

 

is the key.

 

In Documentation it stays in the code example for DOM-Class.

 

 

All Answers

SuperfellSuperfell

You might need to set a content-type HTTP header, and you may need to include an xml dec in your payload 

ccoltccolt

Hi,

 

thanks a lot SimonF.

 

 

request.setHeader('Content-Type', 'text/xml');

 

is the key.

 

In Documentation it stays in the code example for DOM-Class.

 

 

This was selected as the best answer