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

URGENT - Can i directly send/receive SOAP Messages with out using the Salesforce API ?

I am sending a soap message by posting it to the SOAP Server via a HTML Form using the below code. But i get a SOAP fault in response shown below. Can some one please put some light on what the SOAP Server needs ?? I am using the login to the Salesforce Developer edition account.
<title>XML Client for soap Servlet Example</title>
<h4>Web based SOAP Client</h4>
You can use the form below to <tt>POST</tt> XML requests to the servlet URL -
<form method='POST' action=''><textarea
 name='xml' rows='10' cols='60'>
<?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:soap=""
xmlns:xsi="" xmlns:xsd="http://">
         <login xmlns="">
</textarea> <br>
<input type='submit' value='Send'> | <input type='reset' value='Clear'>
  <?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">
- <soapenv:Body>
- <soapenv:Fault>
  <faultcode xmlns:ns1="">ns1:UNKNOWN_EXCEPTION</faultcode>
  <faultstring>UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService</faultstring>
- <detail>
- <sf:fault xsi:type="sf:UnexpectedErrorFault" xmlns:sf="">
  <sf:exceptionMessage>Destination URL not reset. The URL returned from login must be set in the SforceService</sf:exceptionMessage>
The SOAP endpoint requires a real soap message (i.e. one that conforms to both the SOAP 1.1 specification, and the XML schema contained within the WSDLs).

You can't generate a SOAP request from an HTML FORM Post, what you're generating is a form encoded request where part of that encoded request is a chunk of XML, this is not SOAP, a soap request contains the XML directly, has a HTTP content-type of text/xml; charset='someCharSetProbablyutf-8' and a HTTP header called SOAPAction.

Use a proxy or sniffing tool and compare the POST generated by your FORM to a POST from a soap client (or from the sample messages linked from the docs), you'll be able to see the difference.
I have tried two different ways to send the Login message.
A) Build SOAP message using soap tool kit and send it using a inhouse customized http client. The request message using this method looks as below and the corresponding output is a SOAP fault and hence we see a HTTP error.

REQUEST :SOAPMessage: msg = [SOAPEnvelopeHDOMImpl:

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">

<SOAP-ENV:Header />


<login xmlns="">

<username xmlns=""></username>

<password xmlns="">*****</password>




]; attributes = [{HEADER_MAP={Cookie=SMSESSION=EmHyJYcUOApHLMAXhiPiVLjfbTqtdWcI4WNf9t9QeZxSQiqcYKDgGWF1g5NFVPTzTeXoRz2+PYNjumh/MABqV6b5gnjKhnjMBtH206sXWP87BS1BV8Iw1biKKqPSCETEie3O0kWvnpyuU1Xn9W2PKTddcy7mBGU1JsGcspOwE3I+ECYPK2GFoTQ00lyNFdCpAk1msynxoRJskts+M9dALW98GZGyjfeO6MlzAwKW5iQfCOgz8uptSEvLQ56CJfC5C2FLwP+cURZFQJBFllNEAM3It0lnEyrrrBwCzgK+FxkOTjvVcUuo/kkESph20Zj5FTbJs0kjKGT6toRngCBN/TUM4JrGpL5VGkkxCzvtU8oXvctneRTc2PhLKaLKmE4s, SOAPAction=}}]

msjava.soaptk.common.SOAPException: Unexpected response: HTTP_SERVER_ERROR with no content in the body! Status code: 500; transport name =, protocol HTTP

at msjava.soaptk.transport.http.SOAPHttpClient.sendRequest(

at Login.<init>(

at Login.main(

B) using a HttpsURLConnection to send the messgae. Below is the output of it. Server returned HTTP response code: 500 for URL:



at URLSample.main(

error: <?xml version="1.0" encoding="UTF-8"?>

error: <soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">

error: <soapenv:Body>

error: <soapenv:Fault>

error: <faultcode xmlns:ns1="">ns1:UNKNOWN_EXCEPTION</faultcode>

error: <faultstring>UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService</faultstring>

error: <detail>

error: <sf:fault xsi:type="sf:UnexpectedErrorFault" xmlns:sf="">

error: <sf:exceptionCode>UNKNOWN_EXCEPTION</sf:exceptionCode>

error: <sf:exceptionMessage>Destination URL not reset. The URL returned from login must be set in the SforceService</sf:exceptionMessage>

error: </sf:fault>

error: </detail>

error: </soapenv:Fault>

public class Login {
 SOAPHttpClient client;
 SOAPMessage loginResponse;
 Login(String uname, String pwd) {
 SOAPEnvelope envelope = new SOAPEnvelopeHDOMImpl();
 SOAPHeader header = envelope.createHeader(); 

    Element username = new Element("username");
    Element password = new Element("password");
//  build body 
 SOAPBodyHDOMImpl body = (SOAPBodyHDOMImpl) envelope.createBody(); 
 SOAPActionHDOMImpl action = new SOAPActionHDOMImpl("login"); 
 try {
 }catch(SOAPException e) {
    SOAPMessage request = new SOAPMessage(envelope);

/....customized code to generate token .../

    Map m = new HashMap();
    m.put("Cookie", "SMSESSION="+ token);
    request.getAttributes().put(TIAFHttpAttributes.HEADER_MAP, m);

    System.out.println("REQUEST :" + request);
     try  {
     client = new SOAPHttpClient("");
     } catch(IOException e){
    try {
     loginResponse = client.sendRequest(request);
    } catch(SOAPException e) {
 public static void main(String args[]) {
  Login login = new Login("", "*****");
METHOD Bimport*;
public class URLSample { /**
  * @param args
 public static void main(String[] args) {
   HttpsURLConnection connection = null;
  try {
        URL u = new URL("");
        URLConnection uc = u.openConnection();
        connection = (HttpsURLConnection) uc;
     connection.setRequestProperty("SOAPAction", "\"\"");
   connection.setRequestProperty("Expect", "100-continue");
   connection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
   connection.setRequestProperty("Host", "");
        Writer wout = new OutputStreamWriter(connection.getOutputStream());
        wout.write("<?xml version=\"1.0\" encoding=\"utf-8\"?\r\n");
        wout.write("<soap:Envelope ");
        wout.write("xmlns:xsi=\"\" xmlns:xsd=\"\"\r\n");
        wout.write("<login xmlns=\"\"\r\n");
        InputStream is = connection.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        while ( (line = br.readLine()) != null) {
         System.out.println("result: " + line);
       catch (IOException e) {
        InputStream es = connection.getErrorStream();
        InputStreamReader isr = new InputStreamReader(es);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        try {
        while ( (line = br.readLine()) != null) {
         System.out.println("error: " + line);
        }catch (IOException errio) {
 } }


Message Edited by dimple on 09-13-2006 01:46 AM

Message Edited by dimple on 09-13-2006 05:40 AM

What does a wire capture of your request look like (HTTP headers + soap message) ?


I am using ethereal to get the wire capture but since the connection is HTTPS all the data is encrypted.

Doh !!

Is there any way to see the data ?






Message Edited by dimple on 09-13-2006 01:08 PM


hi, i changed the url from https to http and found out some thing wrong i was doing. fixed that and then i got the below error. You were right that i should use soap tool kit to create the message. So i plan to continue with the soap tool kit to figure out what is going wrong there. Will pick up that tommorrow morning. After this learning I bet that the message format is the problem ... need to play around more.

thanks again, dimple :-) Server returned HTTP response code: 500 for URL: http://www
        at URLSample.main(
error: <?xml version="1.0" encoding="UTF-8"?>
error: <soapenv:Envelope xmlns:soapenv="
/" xmlns:xsd="" xmlns:xsi="
error:  <soapenv:Body>
error:   <soapenv:Fault>
error:    <faultcode>soapenv:Server</faultcode>
error:    <faultstring>org.xml.sax.SAXParseException: Element type &quot;soap:En
velope&quot; must be followed by either attribute specifications, &quot;&gt;&quo
t; or &quot;/&gt;&quot;.</faultstring>
error:    <detail/>
error:   </soapenv:Fault>
error:  </soapenv:Body>
error: </soapenv:Envelope>