Problem in sending a attachnment or photo using javamailapi

Hello Sir,
My program is perfectly when i'm sending simply a text message but problem is arised when i want to send an attachment.
MY Code is
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
import javax.activation.*;
import java.util.Properties;
public class SendAtthachment
private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final String SMTP_AUTH_USER = "[email protected]";
private static final String SMTP_AUTH_PWD = "hindustan";
private static final String fname= "my.jpg";
private static final String emailMsgTxt = "motion is detected,some one is in your home";
private static final String emailSubjectTxt = "motion";
private static final String emailFromAddress = "[email protected]";
private static final String[] emailList = {"[email protected]", "[email protected]"};
public static void main(String args[]) throws Exception
SendAtthachment smtpMailSender = new SendAtthachment();
smtpMailSender.postMail( fname,emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");
public void postMail( String filename,String recipients[ ], String subject, String message , String from) throws MessagingException
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587") ;
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
addressTo[i] = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
BodyPart msgBP = new MimeBodyPart();
msg.setText("Take a look at this");
Multipart mpart = new MimeMultipart();
mpart.addBodyPart(msgBP);
msgBP = new MimeBodyPart();
DataSource src = new FileDataSource(filename);
msgBP.setDataHandler(new DataHandler(src));
msgBP.setFileName(filename);
mpart.addBodyPart(msgBP);
msg.setContent(message, "text/plain");
msg.setContent(mpart);
Transport.send(msg);
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
And this exception arised at run time-
E:\gaurav\study material\motion detector\Motion Detector>java SendAtthachment
Exception in thread "main" javax.mail.MessagingException: IOException while send
ing message;
nested exception is:
java.io.IOException: No content
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at SendAtthachment.postMail(SendAtthachment.java:76)
at SendAtthachment.main(SendAtthachment.java:25)
Caused by: java.io.IOException: No content
at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSou
rce.java:119)
at javax.activation.DataHandler.writeTo(DataHandler.java:318)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:874)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:444)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:10
2)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:89
7)
at javax.activation.DataHandler.writeTo(DataHandler.java:330)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:636)
... 4 more
E:\gaurav\study material\motion detector\Motion Detector>

You're creating a body part for the attachment, but you also need to
create a body part for the main text of your message. See the sendfile.java
demo program included with JavaMail for an example.

Similar Messages

  • Photosmart C7280 -how do I scan and send a document or photo using windows7 home premium?

    I have a 7280 photosmart. I am older generation computer illiterate-please can someone tell me how to scan and send a document or photo using windows7 home premium (64)

    Hi scotka
    I know this is a few weeks ago but I see no one replied. You'll find information on how to scan in the manual (~ pg118). Any hassles just let me know....
    http://h10032.www1.hp.com/ctg/Manual/c01102249.pdf
    Ciara
    Although I am an HP employee, I am speaking for myself and not for HP.
    Twitter: @Ciara_B_HP

  • Problems with sending IDocs into R/3 using BPM

    Hi Vishnu,
    as I have read the forum, you have experience with sending IDocs into R/3 from XI using the BPM.
    Did you have problem, that this sending takes very long time?
    My BPM splits the xml, sends IDoc into R/3 immediately, but the processing of the 2nd IDoc takes 6-10 minutes!
    Do you have any idea, what could be wrong?
    Thanx 4 answer, Peter

    Vishnu, I was discussing this problem in another thread, but no helpful answer was sent, and I have read, that you have experience, so - just for explanation
    Well,
    yes, this situation is really strange.. New facts are:
    when I send into XI XML, which is splitted in the BPM only into 1 IDoc, it is processed immediately. When I send there XML for 2 IDocs, the first is processed immediately, the 2nd starts immediately, but end of process is after 6-10 minutes, it depends... Then I tried to send there XML for 10 IDocs - and now attention please! 5 of them have been processed almost immediately, 5 of them after 8 minutes...  The last test was with 16 items - 6 processed immediately, 10 after 10 minutes...  And all these 10 minutes was my 4 processor XI box unavailable, with over 60% load... But finally the IDocs arrive!!
    Any explanation???
    This is really unbelievable situation!
    Port name is SAPDEV, rfc destination DEVCLNT100
    Actually, when I was creating the scenarion using the wizard and trying to add my communication channel(IDoc type) to receiver agreement, I got error - communication channel is not configured correctly, use another one. But somewhere I read, that I should create the receiver agreement manually. So I did.
    To my BPM:
    -receive MSG
    -switch (but I'm testing only one branch now) - and the MSG message is always passed here, it's ok
    -then I have transformation to MultiMSG (message with multiple DATA for multiple IDOCS)
    -then comes the split mapping Multi2SingleMSG
    -then ForEach Block with sending the Single MSG
    this is the end of the BPM, and outside the BPM comes the mapping Single2IdocMSG and sending the IDoc into R/3
    before I had the Single2Idoc mapping in the BPM, but thought, that this could be the bottleneck, so moved the mapping after the BPM... It didn't help...
    So, what do you say?
    Peter

  • I've upgraded to iOS 7.0.2. I'm having problems now sending thru iMessage although my account is verified, I've upgraded to iOS 7.0.2. I'm having problems now sending thru iMessage although my account is verified

    Hello everyone. My name is Jogi from the Philippines. I've encountered a problem with sending iMessages. I'm using iPhone 5 and I've upgraded it to iOS 7 then 7.0.2. After updating to iOS 7 I've already encountered the problem. However upon updating to 7.0.2 it got better for a while then the next day the problem with sending iMessage returned.
    My account is verified since I've been using iMessage for more than two years now and signal is great coz I have to make use of viber app to send messages online. I've already deactivated and activated iMessage service for a few times, account is verified. Still is hasn't improved for about a week now.
    Any ideas?

    There are iMessage problems. Some report that a reset has worked, others say to go to Settings>General>Reset>Reset All Settings or Reset network settings. Apple is aware of the problem and is working on an update. Should be released very soon.

  • I can use Mail at home, no problem. But when I travel, I can receive mail but not send it. I get a "server can't be reached" message. Yet when I send a photo using iPhoto, it gets sent. Help!!

    I can use Mail at home, no problem. But when I travel, I can receive mail but not send it. I get a "server can't be reached" message. Yet when I send a photo using iPhoto, it gets sent. Help!!

    To diagnose problems with Thunderbird, try the following:
    *Restart the operating system in '''[http://en.wikipedia.org/wiki/Safe_mode safe mode with Networking]'''. This loads only the very basics needed to start your computer while enabling an Internet connection. Click on your operating system for instructions on how to start in safe mode: [http://windows.microsoft.com/en-us/windows-8/windows-startup-settings-including-safe-mode Windows 8], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-7 Windows 7], [http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-vista Windows Vista], [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/boot_failsafe.mspx?mfr=true" Windows XP], [http://support.apple.com/kb/ht1564 OSX]
    ; If safe mode for the operating system fixes the issue, there's other software in your computer that's causing problems. Possibilities include but not limited to: AV scanning, virus/malware, background downloads such as program updates.

  • What is an smpt password?  I have problems sending photos using the stamp at the bottom because it asks for some smpt password and I have no clue to find out what it is, how to set one of find one if I somehow put one in and don't know what it it.

    what is an smpt password?  I have problems sending photos using the stamp at the bottom because it asks for some smpt password and I have no clue to find out what it is, how to set one of find one if I somehow put one in and don't know what it it.

    It's the password for your outgoing mail in your Mail account. You need to set it up in your Preferences.
    Regards
    TD

  • Mail and iPhoto Problems with sending photos.

    Mail and iPhoto Problems with sending photos.
    I have this problem that started a while ago and seems to be getting worse.
    Here are the different scenarios.
    -If I try to share a photo to email within iPhoto, it will insert the image file name in the mail message, but no image icon or opened image. In iPhoto Preferences under General I have chosen to use Email Photos using Mail.
    -If I choose to use iPhoto to send the photo, it will compose the message and the photo is viewable. If I send the message i can view the photo within the email I sent to myself. Nothing happens when I double click on the photo in the Mail message. Nothing happens when i control click on the photo in the mail message. Nothing happens when I try to drag the photo to the desktop from the mail message. When I try to save attachments from the email and choose a place to save it, the save button is grayed out and it cannot be saved. When I check the mail message it says there is an attachemnt but there is no file size listed.
    -If I use the stationary within Mail app I cannot drag a photo into the placeholder, I get a circle with a line through it symbol when I try. It happens if I try to drag a photo from the desktop or from the media browser within Mail app.
    -If I drag the photo to the desktop from iPhoto, I can double click it on the desktop and it will open in Preview.
    -If I then control click on the same photo on the desktop and scroll to share/email, the generic photo icon will be inserted in the mail message. If i double click the photo icon in the mail message  I get a message it can't be opened because it is empty.
    -If I drag that same image to the mail message body the same thing happens.
    -If I send that email to someone they cannot open the image file.
    What I can do:
    - I can drag that same image file on the desktop to my dropbox folder and  it will upload. From there I can go on my iPad and download the photo and send it through email just fine.
    -I can open the same image file on my desktop in Preview, I can copy and paste it into a mail message and the image will be viewable in the mail message by me and by the recipient.
    -I can drag that same image on the desktop to my safari browser window and it will be viewable in the page. i can then copy and paste that image into a mail message and it is viewable in the message.  I can then send that email message to myself and i can control click on the image and get all my options. It also shows as an attachment with the size of the image file in the mail message.
    I can send that message to someone and they can see the photo and open it fine.
    -If I send that same email to me I can see the photo within the mail.  If I then drag that photo to the desktop I cannot use it again to put in an email as the same problem happens again.
    I have tried all scenarios in my user account, another users account and in a guest account. The same happens in all. I am guessing because of this it is not a corrupt preference file, unless all of the preference files are corrupt. The guest user account I added a new email account so it was brand new and still had the problem.
    I am stumped, all and any help is appreciated.

    Another problem that may be related….
    I have Snapz Pro. I used to be able to save the snaps to my desktop or a folder. Now when I take a screenshot and try to save the file to my desktop or a folder on my desktop I get this message  "Files cannot be created in the selected location. You do not have permission to write to the selected location.   Please choose a different location."  I have found that i can only save the file to the clipboard.   I have repaired permissions many times and still I have this problem.

  • I have read all the questions regarding the "Can't send photo using iMessage".

    I have read all the questions regarding the "Can't send photo using iMessage". I followed everything and check everything that was in it. It's still the same. I am still not able to send a photo. It started happening last week. It was fine before that. There is no error message.
    It will try to send but it will get stuck just before it sends
    and the red ! will appear with the "Not Delivered" status.
    When i tap on the !, it just says "This iMessage was not delived".
    No other message or photo is sending as the same time as the photo.
    I did reset it, I checked the email address, removed it as well. Turned it off then back on. Signed out and signed back in. Wi-Fi strength is very good. iOS is 6.0.1. I checked for updates, it is up-to-date I also checked a link http://support.apple.com/kb/TS2755. It did not help at all.
    What's wrong?!?!?!?!

    It is not a matter of reconsidering the decision. There are unsolveable technical problems with trying to run a program such as Firefox on Blackberry OS. We would need Blackberry to distribute a tool similar to Android's NDK to run on Blackberries.

  • The Java plugin has created a time unfriendly issue with my e-mail account, I can not open or send any e-mail without using this plugin, how can I eliminate this problem without dropping m. firefox?

    A few days ago I tried to e-mail a friend, when I started A box came up and it required me to add a plugin..Java. I contacted my e-mail courier and microsoft, they told me that is was a plugin from Mozilla Firefox. Since then I must go through Java to send or open an e-mail... this is NOT to my satisfaction, it takes too long for all of this to open and if it is not cleared , I am dropping Mozilla and going elsewhere. Why has this occurred? Is this a result of the last update? If so can I delete the last update and continue on the other version?
    == This happened ==
    Every time Firefox opened
    == last week

    Sorry, I have no idea what you mean by '''"The Java plugin has created a time unfriendly issue with my e-mail account, I can not open or send any e-mail without using this plugin,"'''.
    If you think your problem is caused by the Java plugin, you should visit the Java support forum for assistance.
    http://forum.java.sun.com/index.jspa
    If you could explain what you mean by '''"time unfriendly''' issue with my e-mail account", maybe we'll be able to help you solve that issue.
    It might be helpful for us if we knew exactly which web-mail provider you are using. It seems strange to me that viewing or sending web-mail would actually "need" Java for operation, its more likely that some other item on the web page needs Java to run some advertising or other garbage that isn't a necessary part of the web-mail functionality you want to use.

  • Problem in sending messages using java mail api

    Hi All,
    I have a problem in sending messages via java mail api.
    MimeMessage message = new MimeMessage(session);
    String bodyContent = "ñSunJava";
    message.setText (bodyContent,"utf-8");using the above code its not possible for me to send the attachment. if i am using the below code means special characters like ñ gets removed or changed into some other characters.
    MimeBodyPart messagePart = new MimeBodyPart();
                messagePart.setText(bodyText);
                // Set the email attachment file
                MimeBodyPart attachmentPart = new MimeBodyPart();
                FileDataSource fileDataSource = new FileDataSource("C:/sunjava.txt") {
                    public String getContentType() {
                        return "application/octet-stream";
                attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                attachmentPart.setFileName(filename);
                Multipart multipart = new MimeMultipart();
                multipart.addBodyPart(messagePart);
                multipart.addBodyPart(attachmentPart);
                message.setContent(multipart);
                Transport.send(message);is there any way to send the file attachment with the body message without using MultiPart java class.

    Taken pretty much straight out of the Javamail examples the following works for me (mail read using Thunderbird)        // Define message
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            // Set the 'to' address
            for (int i = 0; i < to.length; i++)
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    // Set the 'cc' address
    for (int i = 0; i < cc.length; i++)
    message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
    // Set the 'bcc' address
    for (int i = 0; i < bcc.length; i++)
    message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
    message.setSubject("JavaMail With Attachment");
    // Create the message part
    BodyPart messageBodyPart = new MimeBodyPart();
    // Fill the message
    messageBodyPart.setText("Here's the file ñSunJava");
    // Create a Multipart
    Multipart multipart = new MimeMultipart();
    // Add part one
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    for (int count = 0; count < 5; count++)
    String filename = "hello" + count + ".txt";
    String fileContent = " ñSunJava - Now is the time for all good men to come to the aid of the party " + count + " \n";
    // Create another body part
    BodyPart attachementBodyPart = new MimeBodyPart();
    // Get the attachment
    DataSource source = new StringDataSource(fileContent, filename);
    // Set the data handler to this attachment
    attachementBodyPart.setDataHandler(new DataHandler(source));
    // Set the filename
    attachementBodyPart.setFileName(filename);
    // Add this part
    multipart.addBodyPart(attachementBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send(message);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I can not send my Note through email and it used to work. The same problem to send picture from iPhone message

    Can't send Notes through email and it used to work. The same problem of sending picture from iPhone message. Did the reset twice but still not working

    Try a reset:
    Hold the Sleep and Home button down for about 10 second until you see the Apple logo.

  • Problem while sending/Receiving request using the HttpURLConnection obj

    Hi,
    We are facing the problem while passing the request in Weblogic.
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    Currently we are migrating 2 applications to WebLogic. Application1 to application2 request should pass.
    Below is some example we tried:
    "When we send a request to our code using the SSOAdaptor code (which handles the request/session in our application) which is on the SunOne server the request parameters are received by our code successfully. And also in Create User Functionality of application1 we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass."
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues.
    Where as when the request is sent from WebLogic to WebLogic the request parameters are missing some how.
    Is there any issue in Weblogic? Please helpus on this.
    Thanks,
    Nagesh
    Edited by: user9307541 on Mar 15, 2010 5:08 AM

    Hi,
    Please find below scenario for testing.
    We have tested the SSOAdaptor code (it is the fucntion name which will send the data from source) locally by hittiing the WPS adaptor URL in a Java client program(TestRequest.java) and the request parameters were reaching the WPS Adapter successfully.
    Then we have written two test servlets to test the communication between SSOAdaptor(TestServlet.java) and WPS adaptor(WPSServlet.java).
    Functionality of TestSevlet: It is sending a request to WPSServelt similar to the way we are doing it in SSOAdaptor.
    Functionality of WPSServlet: It will receive the request parameters and write the parameter Map to console.
    We have deployed and these two servlets(in a single webapplication) on Tomcat server and the request parameters are reaching the WPSServlet successfully.
    Output on Tomcat server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{TypeAcc=[Ljava.lang.String;@14e3f41, ServiceName=[Ljava.lang.String;@1acd47, GMEPortalUserID=[Ljava.lang.String;@19b04e2, UserID=[Ljava.lang.String;@5dcec6, Country=[Ljava.lang.String;@b25b9d}
    after sending request
    After this we have deployed these two servlets (with in a single webapplication) on the Weblogic server in Dev machine(path: /apps/usmport/domains/usmport/servers/usmport_admin/upload/ssoAdaptor/WEB-INF/classes/com/gm/gmeportal/security/adaptor) and
    now the request parameters are not reaching the WPSServlet.
    Output on Weblogic Server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{}
    after sending request
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    When we send a request to WPSAdaptor using the Old SSOAdaptor code which is on the SunOne server the request parameters are received by WPS successfully. And also in Create User Functionality of Portal we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass.
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues. Where as when the request is sent from weblogic to weblogic the request parameters are missing some how.
    Please find below javs source code used to test this:
    TestRequest.java
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestRequest {
         * @param args
         public static void main(String[] args) throws Exception{
              // TODO Auto-generated method stub
              excutePost("http://localhost:8080/Testing/TestServlet", "GMEPortalUserID=captest.wss@it0555&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
              //System.out.println("********** Now the request is from SSO *****************");
              //excuteGet("http://10.156.0.173:7013/channel21/wpsadapter", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
         public static String excutePost(String targetURL, String urlParameters)
         URL url;
         HttpURLConnection connection = null;
         try {
         //Create connection
         url = new URL(targetURL);
         connection = (HttpURLConnection)url.openConnection();
         connection.setRequestMethod("POST");
         connection.setRequestProperty("Content-Type",
         "application/x-www-form-urlencoded");
         connection.setRequestProperty("Content-Length", "" +
         Integer.toString(urlParameters.getBytes().length));
         connection.setRequestProperty("Content-Language", "en-US");
         connection.setUseCaches (false);
         connection.setDoInput(true);
         connection.setDoOutput(true);
         //Send request
         DataOutputStream wr = new DataOutputStream (
         connection.getOutputStream ());
         wr.writeBytes (urlParameters);
         wr.flush ();
         wr.close ();
         //Get Response     
         InputStream is = connection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(connection != null) {
         connection.disconnect();
         public static String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    TestServlet.java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class TestServlet
    public class TestServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * Default constructor.
    public TestServlet() {
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doPost(request,response);
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              //System.out.println("********************** the request Map is:" + request.getParameterMap());
              try {
                   System.out.println("before sending request");
                   excuteGet("http://localhost:7003/ssoAdaptor/WPSServlet", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
                   System.out.println("after sending request");
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         //System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    WPSServlet.java
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class WPSServlet
    public class WPSServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * @see HttpServlet#HttpServlet()
    public WPSServlet() {
    super();
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              System.out.println("**********************Inside WPS Servlet -- the request Map is:" + request.getParameterMap());
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doGet(request,response);
    Thanks,
    Nagesh

  • Problem while sending the message using RWB

    Dear All,
    I am facing a problem while sending a message from RWB. I sent the message using Test Message in component monitoring, it says message sent but I am not able to see any message in sxi_monitor.
    When I send the same message using the http client it successfully processed by XI and I can see the success message in sxi_monitor.
    Please let me know if anyone has face similar kind of issue.
    Thanks,
    Alok
    Edited by: Alok Raoka on May 26, 2008 5:08 PM

    Dear All,
    I am facing a problem while sending a message from RWB. I sent the message using Test Message in component monitoring, it says message sent but I am not able to see any message in sxi_monitor.
    When I send the same message using the http client it successfully processed by XI and I can see the success message in sxi_monitor.
    Please let me know if anyone has face similar kind of issue.
    Thanks,
    Alok
    Edited by: Alok Raoka on May 26, 2008 5:08 PM

  • Please help: Problem sending fax to one recipient using Apple USB Modem

    Hello,
    I'm using an Apple USB Modem to send an receive faxes on my PowerMac G5. This is working great to the most recipients, but not one with a Philips fax machine.
    The problem is, that everybody can send faxes to him - except of me
    I'm using a software called Pagesender for this, I e-mailed the support and he told me, that the my fax is timing out and some of his customers have made positive reports of Zoom and Best Data Modems in cases where the Apple Modems have encountered line noise.
    Also the Tiger fax solution doesn't work ... The odd things are, that I could send faxes using a stationary fax machine and don't have problems to send faxes to others ...
    Is there really no solution for this.
    Best regards
    René

    Hello,
    I'm using an Apple USB Modem to send an receive faxes on my PowerMac G5. This is working great to the most recipients, but not one with a Philips fax machine.
    The problem is, that everybody can send faxes to him - except of me
    I'm using a software called Pagesender for this, I e-mailed the support and he told me, that the my fax is timing out and some of his customers have made positive reports of Zoom and Best Data Modems in cases where the Apple Modems have encountered line noise.
    Also the Tiger fax solution doesn't work ... The odd things are, that I could send faxes using a stationary fax machine and don't have problems to send faxes to others ...
    Is there really no solution for this.
    Best regards
    René

  • Problems in sending Scheduling Agreement Change using ORDCHG

    Hi All,
    I am having problem while sending Scheduling Agreement change from a source system to a target system using ORDCHG in ALE,
    Its going to ORDERS and creating a fresh new Sales Order instead of creating ORDCHG idoc's & creating a new order only for the chages.
    Please provide some inputs on what Messge Types can support Scheduling Agreement change to Sales Order change.
    Regards
    Rajendra.

    Hi Pavan,
    Thanks for ur suggestion.
    I have tried with DELINS message type, the IDoc is getting created but in the receiver side the status always remains 51 with message Vendor XXXXX not saved for the customer YYYYY.
    Thanks
    Rajendra

Maybe you are looking for