package cn.lihu.jh.module.ecg.webservice;
|
|
import cn.lihu.jh.module.ecg.webservice.ws.JHFWreq;
|
import cn.lihu.jh.module.ecg.webservice.ws._0020SAMPLEBS_0020;
|
import cn.lihu.jh.module.ecg.webservice.ws._0020SAMPLEBS_0020Soap;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Component;
|
|
import javax.xml.ws.BindingProvider;
|
import java.net.URL;
|
|
/**
|
* WebService客户端
|
*/
|
@Slf4j
|
@Component
|
public class WebServiceClient {
|
|
private static final String WSDL_URL = "http://10.0.4.36/ZHIP/Service/ZHIP.JHFWTYRK.BS.JHFWTYRK.cls?wsdl";
|
private static final String ENDPOINT_URL = "http://10.0.4.36/ZHIP/Service/ZHIP.JHFWTYRK.BS.JHFWTYRK.cls";
|
|
/**
|
* 调用JHFWTYRK服务
|
*
|
* @param action 操作类型
|
* @param rdn 请求标识
|
* @param message 消息内容
|
* @return 响应结果
|
*/
|
public String callJHFWTYRK(String action, String rdn, String message) {
|
try {
|
// 创建服务实例
|
_0020SAMPLEBS_0020 service = new _0020SAMPLEBS_0020(new URL(WSDL_URL));
|
_0020SAMPLEBS_0020Soap port = service.get_0020SAMPLEBS_0020Soap();
|
|
// 设置端点地址
|
BindingProvider bindingProvider = (BindingProvider) port;
|
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ENDPOINT_URL);
|
|
// 设置超时时间(可选)
|
bindingProvider.getRequestContext().put("javax.xml.ws.client.connectionTimeout", "30000");
|
bindingProvider.getRequestContext().put("javax.xml.ws.client.receiveTimeout", "30000");
|
|
// 构建请求参数
|
JHFWreq req = new JHFWreq();
|
req.setAction(action);
|
req.setRdn(rdn);
|
req.setMessage(message);
|
|
// 调用服务
|
String response = port.jhfwtyrk(req);
|
log.info("JHFWTYRK调用成功,响应结果:{}", response);
|
return response;
|
|
} catch (Exception e) {
|
log.error("JHFWTYRK调用失败", e);
|
throw new RuntimeException("调用JHFWTYRK服务失败", e);
|
}
|
}
|
}
|