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
Jeff JinJeff Jin 

Can not login by sending request by Socket direct?

hi,

Below is my code.

// begin..

String        rq3 = "<?xml version=\"1.0\" encoding=\"UTF-8\"><SOAP_ENV:Envelope xmlns:SOAP_ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+
            "<SOAP-ENV:Body><ns:login xmlns:ns=\"urn:partner.soap.sforce.com\"><ns:username>jeffj@sz.webex.com</ns:username><ns:password>gowebex</ns:password></ns:login></SOAP-ENV:Body></SOAP-ENV:Envelope>";

            homeURL = "http://www.salesforce.com/services/Soap/u/2.5";
            URLConnection connection = null;
            URL netSerivce = new URL(homeURL);
            connection = netSerivce.openConnection();
            connection.setDoOutput(true);

            out = new BufferedOutputStream(connection.getOutputStream());
            out.write(rq.getBytes(), 0, request.length());
            out.flush();

            try {
                in = new BufferedReader(
                    (new InputStreamReader(connection.getInputStream())));
                int count = 0;
                while ( (getmessage = in.readLine()) != null) {
                    response.append(getmessage + "\n");
                }
            }
            catch (java.io.IOException ex) {
                ex.printStackTrace();
            }

        }
        catch (java.io.IOException e) {
            e.printStackTrace();
        }

        return response.toString();


// --End

the response i got always below:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
   <faultstring>no SOAPAction header!</faultstring>
   <detail/>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>

I don't know what i can do because i don't know the reason.

could you help me check it? thanks.

-Jeff