龚宝雄
7 months ago
26 changed files with 735 additions and 352 deletions
@ -0,0 +1,91 @@ |
|||
package org.nl.wms.ext.srm; |
|||
|
|||
|
|||
import com.alibaba.fastjson2.JSON; |
|||
import com.alibaba.fastjson2.JSONObject; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.axis.client.Call; |
|||
import org.apache.axis.client.Service; |
|||
import org.apache.axis.message.SOAPHeaderElement; |
|||
import org.nl.wms.ext.eas.WSContext; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.xml.namespace.QName; |
|||
import javax.xml.rpc.ServiceException; |
|||
import java.rmi.RemoteException; |
|||
|
|||
/** |
|||
* WmsToEasService |
|||
* |
|||
* @author gbx |
|||
* @since 2024-03-29 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class WmsToSrmService { |
|||
|
|||
@Value("${srmConfig.host}") |
|||
private String host; |
|||
|
|||
@Value("${srmConfig.user}") |
|||
private String user; |
|||
|
|||
@Value("${srmConfig.password}") |
|||
private String password; |
|||
|
|||
@Value("${srmConfig.datacenter}") |
|||
private String datacenter; |
|||
|
|||
@Value("${srmConfig.wsdlService}") |
|||
private String wsdlService; |
|||
|
|||
@Value("${srmConfig.operationName}") |
|||
private String operationName; |
|||
|
|||
public void sendWebService(String json) throws ServiceException, RemoteException { |
|||
Service s = new Service(); |
|||
Call call = (Call) s.createCall(); |
|||
call.setReturnType(new QName("urn:client", "WSContext")); |
|||
//本地根据wsdl文件建立的返回对象
|
|||
call.setReturnClass(WSContext.class); |
|||
// call.setOperationName("login");
|
|||
// //登录的webservice的wsdl的地址
|
|||
// call.setTargetEndpointAddress(host + "EASLogin?wsdl");
|
|||
// call.setReturnQName(new QName("", "loginReturn"));
|
|||
// //超时时间 自由配置
|
|||
// call.setTimeout(1000 * 60);
|
|||
// call.setMaintainSession(true);
|
|||
// //解决方案:eas
|
|||
// //语言:L2 简体中文 L3 繁体中文
|
|||
// //数据库类型:0 SQL Server 1 Oracle 2 DB2
|
|||
// result = (WSContext) call.invoke(new Object[]{user, password, "eas", datacenter, "L2", 1, "BaseDB"});
|
|||
// //关键点,获取登录时返回的sessionid
|
|||
// String sessionId = result.getSessionId();
|
|||
// System.out.println(sessionId);
|
|||
// //登录失败抛出异常
|
|||
// if (sessionId == null) {
|
|||
// log.error("sendWebService调用结果" + "login Eas Fail");
|
|||
// throw new Exception("login Eas Fail");
|
|||
// }
|
|||
// call.clearOperation();
|
|||
//超时时间 自由配置
|
|||
call.setTimeout(1000 * 60); |
|||
call.setMaintainSession(true); |
|||
call.setTargetEndpointAddress(host + wsdlService + "?wsdl"); |
|||
call.setReturnQName(new QName("", "dealTaskReturn")); |
|||
//具体某个方法
|
|||
call.setOperationName(operationName); |
|||
//关键点 传sessionid
|
|||
//call.addHeader(new SOAPHeaderElement("http://login.webservice.bos.kingdee.com", "SessionId"));
|
|||
//接口报文
|
|||
Object invoke = call.invoke(new Object[]{json}); |
|||
JSONObject jsonObject = JSON.parseObject((String) invoke); |
|||
int results = jsonObject.getIntValue("result"); |
|||
log.error("sendWebService调用:" + "调用成功!"); |
|||
log.error("sendWebService调用结果:" + invoke.toString()); |
|||
log.error("sendWebService调用结果:" + results); |
|||
System.out.println(invoke); |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue