package org.dromara.resource.domain.bo;

import java.io.Serializable;
import java.util.Map;

import cn.hutool.core.util.XmlUtil;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;

/**
 * <p>
 * TODO
 * </p>
 * @author ${USER}
 * @since 2024-10-302 10:01:17
 **/
@Data
public class YsdSendBo implements Serializable {
    public static void main(String[] args) {
       String xmlContent="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://www.huawei.com.cn/schema/common/v2_1\" xmlns:loc=\"http://www.csapi.org/schema/parlayx/sms/send/v2_2/local\">\n" +
            "   <soapenv:Header>\n" +
            "      <v2:RequestSOAPHeader>\n" +
            "         <v2:spId>700040</v2:spId>\n" +
            "        <v2:spPassword>yjy@123</v2:spPassword>\n" +
            "        <v2:serviceId>1</v2:serviceId>\n" +
            "      </v2:RequestSOAPHeader>\n" +
            "   </soapenv:Header>\n" +
            "   <soapenv:Body>\n" +
            "      <loc:sendSms>\n" +
            "         <loc:addresses>tel:18310309618</loc:addresses>\n" +
            "         <loc:message>【云时代】您好，您的验证码是：123456.</loc:message>\n" +
            "          <loc:priority>5</loc:priority>\n" +
            "      </loc:sendSms>\n" +
            "   </soapenv:Body>\n" +
            "</soapenv:Envelope>";
        Map<String, Object> map = XmlUtil.xmlToMap(xmlContent);

        String smsApiUrl="http://192.168.111.91:5010/SendSmsService/services/SendSms?wsdl";
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_XML);

        HttpEntity<String> entity = new HttpEntity<>(xmlContent, headers);
        String url = smsApiUrl;
        String s = restTemplate.postForObject(url, entity, String.class);
        System.out.println(s);

    }
}
