1.项目引入cxf包
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.5</version>
</dependency>
2.在项目下新建webservice文件,右边点击选择WebService
1.png
3.填写webservice接口信息(需要本机要能访问该接口,不然会报错)
2.png
4.自动生成的代码列表如下
3.png
5.webservice接口调用
package com.yudu.sms;
import com.yudu.sms.util.MD5;
import com.yudu.sms.webserviceFile.ISmsOperator;
import com.yudu.sms.webserviceFile.MtMessage;
import com.yudu.sms.webserviceFile.MtMessageRes;
import com.yudu.sms.webserviceFile.SmsOperatorImpService;
import java.util.ArrayList;
import java.util.List;
public class WebServiceCS {
public static void main(String[] args) {
String userName="xxxx"; //用户名
String password="xxxx"; //密码
password = MD5.GetMD5Code(password);
MtMessage mtMessage = new MtMessage();
List<String> phoneNumber = new ArrayList<>();
phoneNumber.add("15823522687");
mtMessage.setPhoneNumber(phoneNumber);
mtMessage.setContent("webservice短信接口测试1105");
SmsOperatorImpService smsOperatorImpService = new SmsOperatorImpService();
ISmsOperator sms = smsOperatorImpService.getSmsOperatorImpPort();
MtMessageRes mtMessageRes = sms.sendSms(userName,password,"",mtMessage);
if(mtMessageRes!=null){
if(mtMessageRes.getSubStat().equals("r:000")){
// TODO
}
}
}
}
网友评论