on 06-09-2005 11:32 AM
Hello All,
I am trying to run an email application through web dynpro, but I am getting following error.
java.rmi.RemoteException: Service call exception; nested exception is: com.sap.engine.services.webservices.jaxrpc.exceptions.InvalidResponseCodeException: Invalid Response Code: (407) Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. ).
I have configured proxy server and port.
I used the method _setUser and _setPassword to set username and password.
What else do I need to do to make this code run?
Please guide.
Regards,
Ashutosh
Hi,
Try using javax.jar file !!!
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashutosh,
Let me know that whether your proxy server needs any authentication for accessing internet?
If yes then have you specified username and password for that?
Sometimes what happens, even we have specified this username and password in application, still we need to manually gives the user name and password.
T do this, access any website from the internet once on server machine. It will ask for user authentication. After authenticated deploy youe application on server and test.
Let me know the status.
Regards,
Bhavik
Hello Bhavik,
Thanks for the suggession.
I have already tried this solution and it has failed.
Yes my IE asks me for proxy authentication, but I have stored the authentication by clicking "Remember my login-password" option.
Hence, IE directly connects me to internet without popping up the authentication dialog box.
I also tried the same solution on other WAS server where IE pops up the authentication dialog; it did'nt work.
Regards,
Ashutosh
No replies?
I was very optimistic about the solution from this forum.
Ashutosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello Ashutosh,
here the server to which u r trying to connect might require authentication. try this code for it:
class SMTPAuthentication extends Authenticator
{
private String name;
private String password;
public SMTPAuthentication(String name, String pwd)
{
this.name = name;
this.password = pwd;
}
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(name,password);
}
}
this is the class that has the method getPasswordAuthentication() which is called automatically.
now in ur code make an object of this method.
eg:
SMTPAuthentication a = new SMTPAuthentication("username","password");
s = Session.getInstance(p,a); // where p is the property object.
i hope you are just trying to send a mail through this server.
regards,
Piyush.
Hello Piyush,
Just to update you,
I am getting following exception if I use your code
javax.mail.SendFailedException: Sending failed; nested exception is:
com.sap.engine.services.javamail.exception.JavaMailMessagingException: Cannot send message to host MailServer:25
using the SMTP protocol
Assume that MailServer is the server I am using to send mails.
On the contrary, I can send mails using JSP/Servlet/Console using same code.
What would you say now?
Regards,
Ashutosh
hello Ashutosh,
i think there is some problem in using ur mail apis. i also got similar execption but it was solved. are u leaving any field like subject etc. can u give the code?
Properties props = new Properties();
props.put("mail.smtp.host", "hostname");
Authenticator a = new SMTPAuthentication("username","pwd");
Session session = Session.getInstance(props, a);
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress("from");
msg.setFrom(addressFrom);
InternetAddress addressTo = new InternetAddress("to");
msg.setRecipient(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
this might help u.
regards,
Piyush.
Following is the code for sending mail.
************Authenctiator class *********
class TheMail extends Authenticator
{
private String name;
private String password;
public TheMail(String name, String pwd)
{
this.name = name;
this.password = pwd;
}
public PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(name,password);
}
}
Sending mails *************
Authenticator mail=new TheMail("myDomainId","password");
Properties props = System.getProperties();
props.put("mail.smtp.host", "myHost");
props.put("mail.smtp.auth","true");
Session sess=Session.getInstance(props,mail);
Message msg1 = new MimeMessage(sess);
msg1.setFrom(new InternetAddress("myId@host.com"));
msg1.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("myId@host.com", false));
msg1.setSubject("I just called to say..");
msg1.setText("...that I can send mail from WebDynpro ");
msg1.setSentDate(new Date());
Transport.send(msg1);
Regards,
Ashutosh
Yes I added the smtp.jar file as you said.
Then I tried
Request_IEmailService_sendMail req = new Request_IEmailService_sendMail();
wdContext.nodeWebServiceEmail().bind(req);
req._setUser("myDomainId");
req._setPassword("passwd");
//........
//.......
But I am getting exception as ...
Proxy Authentication Required ( The ISA Server requires
authorization to fulfill the request. Access to the Web
Proxy service is denied. ).
Regards,
Ashutosh
Message was edited by: Ashutosh Moharir
Hi,
You seems to have used the Web service for mailing.
I was suggesting the JavaMail api
You can refer the following link for assistance.
/people/sap.user72/blog/2005/06/08/sending-attachments-in-mails
Add the smtp.jar file in the build path of the project.
The code given here is in java however it works in webdynpro too
Regards
Noufal
try{
Properties props = new Properties();
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.port","25");
props.put("mail.smtp.host", "host");
Session sess=Session.getInstance(props);
Message msg1 = new MimeMessage(sess);
msg1.setFrom(new InternetAddress("myId@host.com"));
msg1.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("myId@host.com", false));
msg1.setSubject("I just called to say..");
msg1.setText("...that I can send mail from WebDynpro ");
msg1.setSentDate(new Date());
Transport.send(msg1);
}catch(Exception e){
wdComponentAPI.getMessageManager().reportSuccess(e.toString());
}
check if this code works
Regards
Noufal
From the code you had given earlier I too got the same exception that you said(javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.AuthenticationFailedException), but when I produced the following changed it worked for me.
1) change the System.getProperties() to new Properties()
2)remove the authentication true statement.
Hope you have provided the changes?
Just copy paste the code I gave earlier and try. If it still does not work try running it from some other NDS.
Please do let me know.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.