yangys
2025-09-13 083df8d788c95c009a94378e620684eb5de2bd21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
        }
    }
}