刚刚用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();
}