hi,
i am a beginer in web services for CRM on demand. i am repeatedly getting this error and dont know how to fix it
below is the code for inserting a contact into the CRM( confidential information has been replaced by '#" in the following code):
package crmod;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.StringTokenizer;
public class CRMOD {
public CRMOD() {
}
public static void main(String[] args) {
String jsessionid, jsessionid_full;
String endpoint;
try
{
System.setProperty("javax.net.ssl.trustStore", "C:\\Oracle\\Middleware\\jdk160_24\\jre\\lib\\security\\cacerts");
System.setProperty("https.proxyHost", "172.17.24.24");
System.setProperty("https.proxyPort", "8003");
CRMOD crmod = new CRMOD();
System.out.println("Loggin In");
jsessionid_full = crmod.logon("https://secure-slsomxvka.crmondemand.com/Services/Integration", "#####################", "#############");
jsessionid = getSessionId(jsessionid_full);
System.out.println(jsessionid);
endpoint = "https://secure-ausomxdsa.crmondemand.com/Services/Integration" + ";jsessionid=" + jsessionid;
URL urlAddr = new java.net.URL( endpoint);
endpoint = "https://secure-ausomxdsa.crmondemand.com/Services/Integration" + ";jsessionid=" + jsessionid;
urlAddr = new java.net.URL( endpoint);
endpoint = "https://secure-ausomxdsa.crmondemand.com/Services/Integration" + ";jsessionid=" + jsessionid;
urlAddr = new java.net.URL( endpoint);
crmondemand.ws.contact.Contact service = new crmondemand.ws.contact.ContactLocator();
crmondemand.ws.contact.Default_Binding_Contact stub = service.getDefault(urlAddr);
crmondemand.ws.contact.ContactWS_ContactInsert_Input contactlist = new crmondemand.ws.contact.ContactWS_ContactInsert_Input();
crmondemand.ws.contact.ContactWS_ContactInsert_Output outlist = new crmondemand.ws.contact.ContactWS_ContactInsert_Output();
crmondemand.xml.contact.Contact[] contacts = new crmondemand.xml.contact.Contact[1];
crmondemand.xml.contact.Contact contact = new crmondemand.xml.contact.Contact();
contact.setContactFirstName("Bruce");
contact.setContactLastName("Wayne");
contact.setExternalSystemId("4321");
contacts[0] = contact;
contactlist.setListOfContact(contacts);
contactlist.setEcho("off"); // Don’t forget this line, as the Web service call would fail!
outlist = stub.contactInsert(contactlist);
crmondemand.xml.contact.Contact[] results = new crmondemand.xml.contact.Contact[1];
crmondemand.xml.contact.Contact result = new crmondemand.xml.contact.Contact();
results = outlist.getListOfContact();
result = results[0];
System.out.println(result.getContactId());
crmod.logoff("https://secure-slsomxvka.crmondemand.com/Services/Integration", jsessionid_full);
System.out.println("Loggin Out");
}
catch (Exception e)
{
System.out.println(e);
}
}
private static String logon(String wsLocation, String userName,
String password) {
String sessionString = "FAIL";
try {
// create an HTTPS connection to the On Demand webservices
URL wsURL = new URL(wsLocation + "?command=login");
HttpURLConnection wsConnection =
(HttpURLConnection)wsURL.openConnection();
// we don't want any caching to occur
wsConnection.setUseCaches(false);
// we want to send data to the server
// wsConnection.setDoOutput(true);
// set some http headers to indicate the username and passwod we are using to logon
wsConnection.setRequestProperty("UserName", userName);
wsConnection.setRequestProperty("Password", password);
wsConnection.setRequestMethod("GET");
// see if we got a successful response
if (wsConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
// get the session id from the cookie setting
sessionString = getCookieFromHeaders(wsConnection);
}
} catch (Exception e) {
System.out.println("Logon Exception generated :: " + e);
}
return sessionString;
}
/*
* log off an existing web services session, using the sessionCookie information
* to indicate to the server which session we are logging off of
* @param wsLocation - location of web services provider
* @param sessCookie - cookie string that indicates our sessionId with the WS provider
*
*/
private static void logoff(String wsLocation, String sessionCookie) {
try {
// create an HTTPS connection to the On Demand webservices
URL wsURL = new URL(wsLocation + "?command=logoff");
HttpURLConnection wsConnection =
(HttpURLConnection)wsURL.openConnection();
// we don't want any caching to occur
wsConnection.setUseCaches(false);
// let it know which session we're logging off of
wsConnection.setRequestProperty("Cookie", sessionCookie);
wsConnection.setRequestMethod("GET");
// see if we got a successful response
if (wsConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
// if you care that a logoff was successful, do that code here
// showResponseHttpHeaders(wsConnection);
}
} catch (Exception e) {
System.out.println("Logoff Exception generated :: " + e);
}
}
/*
* given a successful logon response, extract the session cookie information
* from the response HTTP headers
*
* @param wsConnection successfully connected connection to On Demand web services
* @return the session cookie string from the On Demand WS session or FAIL if not
found*
*/
private static String getCookieFromHeaders(HttpURLConnection wsConnection) {
// debug code - display all the returned headers
String headerName;
String headerValue = "FAIL";
for (int i = 0; ; i++) {
headerName = wsConnection.getHeaderFieldKey(i);
if (headerName != null && headerName.equals("Set-Cookie")) {
// found the Set-Cookie header (code assumes only one cookie is being set)
headerValue = wsConnection.getHeaderField(i);
break;
}
}
// return the header value (FAIL string for not found)
return headerValue;
}
private static String getSessionId(String cookie) {
StringTokenizer st = new StringTokenizer(cookie, ";");
String jsessionid = st.nextToken();
st = new StringTokenizer(jsessionid, "=");
st.nextToken();
return st.nextToken();
}
}
OUTPUT:
Loggin In
QRmQSvyclJntzQr8YwT1bzNB3CJMP28Mq0K1frmRCDQW2LQYSrSJ!-602288503
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
Process exited with exit code 0.
Please can someone help as i am stuck on this error for quiet some time now.