[b]Hi All
Here the story why we want to use java code:
Current we have below requirement to achieve at our integration. We need to pass cookie manually in the https header for a webservice.
When we checked with software AG document we understood that it is not possible
“Integration Server automatically adds the Cookie header to the HTTP header and supplies any cookies established between Integration Server and the HTTP serverwith which it is interacting. If you supply the Cookie header to transportHeaders, Integration Server prepends the values you supply to the already established Cookie header value”
Current story:
So we concluded to write a java code to invoke the webservice: But the connection fails due to certificate issue.
Included the java.security file to override the SSL authentication. but it fails while compliation as no class found
Please can some one letme know how to hit a service using https protocal and post data in webmethod. Any other option to invoke the webserivce by passing cooke in the header
here is the code snap
try
{
IDataCursor pipelineCursor = pipeline.getCursor();
String Soap_data = IDataUtil.getString( pipelineCursor, “Soap_data” );
String Cookie_SSO = IDataUtil.getString( pipelineCursor, “Cookie_SSO” );
String destUrl = “https://xxxxxxxxxxxxxxxxxxxxxxx”;
//open connection
URL url1 = new URL(destUrl);
HttpsURLConnection connect = (HttpsURLConnection)url1.openConnection();
connect.setDoOutput(true);
connect.setDoInput(true);
connect.setRequestMethod(“POST”);
connect.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”);
connect.setRequestProperty(“Content-Length”, Integer.toString(Soap_data.length()));
connect.setRequestProperty(“Cookie”, Cookie_SSO);
connect.setRequestProperty(“User-Agent”, “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0”);
connect.setInstanceFollowRedirects(false);
TrustManager trustAllCerts = new TrustManager
{
new X509TrustManager()
{
public java.security.cert.X509Certificate getAcceptedIssuers()
{
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate certs, String authType)
{
}
public void checkServerTrusted(java.security.cert.X509Certificate certs, String authType)
{
}
}
};
IDataUtil.put( pipelineCursor, "before ", “yes” );
//Post data
DataOutputStream wr = new DataOutputStream (connect.getOutputStream ());
IDataUtil.put( pipelineCursor, "After ", “yes” );
wr.writeBytes(Soap_data);
wr.flush ();
wr.close ();
// Get Cookie
IDataUtil.put( pipelineCursor, “cookie”, connect.getHeaderField(“Set-Cookie”));
// Get Response
InputStream is = connect.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null)
{
response.append(line);
response.append(‘\n’);
IDataUtil.put( pipelineCursor, “logonResult”, response.toString()
);
}
rd.close();
pipelineCursor.destroy();
connect.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}