package org.springblade.mdm.commons.service; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; @Service @Slf4j public class InternalEmailService { @Autowired private InternalEmailProperties internalEmailProperties; public void send(String fromid,String toids, String ccids, String bccids, String subject, String content, String[] paths) { try { // 创建动态客户端工厂 JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); // 创建客户端 //Client client = dcf.createClient("http://localhost:8080/services/EmailService?wsdl"); Object[] result; try (Client client = dcf.createClient(internalEmailProperties.getMailServiceAddr())) { // 调用方法 result = client.invoke("sendInternalMail", fromid, toids, ccids, bccids, subject, content, null); // 处理响应 if (result != null && result.length > 0) { System.out.println("响应: " + result[0]); } } }catch(Exception e) { log.error("内部邮件发送失败",e); } } }