• ravs316
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0

Hi all, I have problems calling a web service using the POST method. I think that I have the idea of how to do it...:S but Im not sure. Here is my code



public static String sendContent(String url,String parameters)
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url); //this is the http://myws/
req.setBody(parameters);this is like parameters="var1=value1&var2=value2&var3=value3"

req.setHeader('Content-type', 'application/x-www-form-urlencoded');
req.setHeader('Content-length', String.valueOf(parameters.length()) );
HttpResponse res = h.send(req);
return res.getBody();



Now when i execute this the res.getBody() throws me the following error:


 <?xml version='1.0' encoding='ISO-8859-1' ?> <SOAP-ENV:Envelope> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Unknown exception</faultstring> <faultactor>server name:listen port</faultactor> <detail><appSpecific>Unknown Exception has occurred</appSpecific> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>


 I don't really know if I'm setting the headers correctly or what is missing so Ill really appreciate your help.


Thank you for your time