刚刚用javamail实现了一个最简单的发邮件的程序,想通过axis2发布到tomcat上,做成一个webservice调用。
在写客户端测试程序的时候,运行出现如下问题:
Exception in thread "main" org.apache.axis2.AxisFault: java.lang.UnsupportedOperationException: An access occurred that is not valid.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:446)
at org.apache.axis2.description.RobustOutOnlyAxisOperation$RobustOutOnlyOperationClient.handleResponse(RobustOutOnlyAxisOperation.java:91)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at ustc.edu.cn.dxx.mail.SendMailStub.Send(SendMailStub.java:185)
at test.Test.main(Test.java:24)是类型不支持?
请教各位高手,该如何解决啊?先谢过啦!
一下是发邮件程序部分代码
auth = new MyAuthenticator();
Properties props = new Properties();
props.put("mail.smtp.host", addSmtp);
props.put("mail.smtp.auth","true");
Session ssn = Session.getInstance(props, null); MimeMessage message = new MimeMessage(ssn); InternetAddress fromAddress;
try {
fromAddress = new InternetAddress(addFrom);
message.setFrom(fromAddress);
InternetAddress toAddress = new InternetAddress(addTo);
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setSubject(subject);
message.setText(context);
PasswordAuthentication pa = auth.getPasswordAuthentication();
Transport transport = ssn.getTransport("smtp");
transport.connect(addSmtp, pa.getUserName(), pa.getPassword());
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
//transport.send(message);
transport.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在写客户端测试程序的时候,运行出现如下问题:
Exception in thread "main" org.apache.axis2.AxisFault: java.lang.UnsupportedOperationException: An access occurred that is not valid.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:446)
at org.apache.axis2.description.RobustOutOnlyAxisOperation$RobustOutOnlyOperationClient.handleResponse(RobustOutOnlyAxisOperation.java:91)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at ustc.edu.cn.dxx.mail.SendMailStub.Send(SendMailStub.java:185)
at test.Test.main(Test.java:24)是类型不支持?
请教各位高手,该如何解决啊?先谢过啦!
一下是发邮件程序部分代码
auth = new MyAuthenticator();
Properties props = new Properties();
props.put("mail.smtp.host", addSmtp);
props.put("mail.smtp.auth","true");
Session ssn = Session.getInstance(props, null); MimeMessage message = new MimeMessage(ssn); InternetAddress fromAddress;
try {
fromAddress = new InternetAddress(addFrom);
message.setFrom(fromAddress);
InternetAddress toAddress = new InternetAddress(addTo);
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setSubject(subject);
message.setText(context);
PasswordAuthentication pa = auth.getPasswordAuthentication();
Transport transport = ssn.getTransport("smtp");
transport.connect(addSmtp, pa.getUserName(), pa.getPassword());
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
//transport.send(message);
transport.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
解决方案 »
- myeclips中自带的jstl这个包怎么使用
- 关于更新的问题!
- struts2 select标签问题!
- weblogic * 配jdk6
- [在线求助]关于Socket的一个奇怪而简单的问题
- 我在学JAVA想问一下从哪里下载JDK1.3或1.4,JDK有多大呢
- static public int g() 和 public static int g()两个方法有什么区别
- 我的tomcat不能访问了,我看了一下日志文件,大家能不能帮我分析一下原因?
- 新手真的很无力,一个错误找了一晚上也没照出来,求好心人指点
- JAJA程序有类似exe+dll的机制么?
- 关于hibernate中annotation包的问题
- EJB3.0中遇见的一个问题,望大家指点
我也是刚从网上查的,然后自己试着弄……
那应该怎么用java实现发邮件,并能打包成webservice放到服务器上用呢?谢啦!