cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Proxy Authentication Required Error

Former Member
0 Likes
2,484

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

View Entire Topic
Former Member
0 Likes

No replies?

I was very optimistic about the solution from this forum.

Ashutosh

Former Member
0 Likes

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.

Former Member
0 Likes

Hello Piyush,

Thanks for the reply..

But I think you are talking about JavaMail syntax.

I have tried similar code in java mail ( using jsp or servlet ).

But the same code in web-dynpro throws exception.

Have you tried the same code with web-dynpro?

Regards

Ashutosh

Former Member
0 Likes

hello Ashutosh

ya i tried this in WebDynpro and its working fine. im able to send mails. or i think the WAS server in which u r deploying might be requiring the authentication.

also make sure to give ur domain name in the username.

regards,

Piyush.

Former Member
0 Likes

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

Former Member
0 Likes

Please specify if you are using a Javamail application or trying to send mails using the Mail Webservice

If you are using the web service, this problem can occur as some proxies does not allow the use of Web services

Regards

Noufal

Former Member
0 Likes

Hello Noufal,

I am trying both and will adopt the workable solution in my project.

But none of the services are working here and I am not able to send mails.

This problem occurs only if I am using Web-Dynpro for sending mails.

If I use jsp or servlets, I am able to send mails.

Regards,

Ashutosh

Former Member
0 Likes

Try adding the smtp.jar file in your buidpath of your java mail project.

This file can be downloaded from java.sun.com

Former Member
0 Likes

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.

Former Member
0 Likes

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

Former Member
0 Likes

Did you try adding the jar file I told earlier?

I think it would help.

Former Member
0 Likes

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

Former Member
0 Likes

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

Former Member
0 Likes

Hello Noufal,

as I told you earlier, I am trying both the options.

The JavaMail API gives exception as

Cannot send message to host whateverHost:25 using the SMTP protocol.

But the same code will work when I put it in jsp/ servlets.

Is there any trouble in setting webdynpro?

Regards,

Ashutosh

Former Member
0 Likes

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

Former Member
0 Likes

Sorry Noufal,

it gives same exception

Cannot send message to host hostname:25 using the SMTP protocol.

thanks and regards,

Ashutosh

Former Member
0 Likes

This code works well in my system. I was able to send mails.

Try running this application from someother system. My friend also faced this problem.

Hope you are sdding the mail.jar and activation.jar from the plugins given in the plugins folder of your nds.

Regards

Noufal

Former Member
0 Likes

Thats right Noufal,

I am importing mail.jar and activation.jar files.

Thats how I am able to use JavaMail functions

Ashutosh

Former Member
0 Likes

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.

Former Member
0 Likes

Hello Noufal,

stil I am getting the same exception...


Cannot send message to host hostName:25 using the SMTP 
protocol

Ashutosh