泛微OA与SAP通过webservice方式对接数据完整操作

您所在的位置:网站首页 sap接口开发案例 泛微OA与SAP通过webservice方式对接数据完整操作

泛微OA与SAP通过webservice方式对接数据完整操作

2024-07-11 14:05| 来源: 网络整理| 查看: 265

Ecology 9二次开发 java调用SAP 发布的webservice 与OA前端交互

一、接口信息接口描述SAP客户-产品组-销售员关系查询接口接口功能通过客户、销售组织、分销渠道在SAP查询到该客户对应的产品组、销售员、最终客户。接口方向OA--SAP接口程序接口名称urlhttp://SAP域名:8000/sap/bc/srt/wsdl/flv_10002P111AD1/sdef_url/接口名称?sap-client=600类型描述接口字段字段名是否必填是否接口字段字段类型字段长度小数位备注输入参数客户编号I_KUNNRKUNNR必填是CHAR10  销售组I_VKORGVKORG必填是CHAR4  分销渠道I_VTWEGVTWEG必填是CHAR2  输出参数消息类型E_CODE  是CHAR1  S 成功,E 错误,W 警告,I 信息,A 中断处理消息E_MSG  是CHAR220 消息文本输出表  IT_DATA 表名ZOAGETSDTKNVP集团MANDT   CLNT3  客户编号KUNNR   CHAR10  销售组织VKORG   CHAR4  分销渠道VTWEG   CHAR2  终端客户KUNN1   CHAR10  销售员KUNN2   CHAR10  产品组SPART   CHAR

2

  

SAP接口操作

se37命令可查看接口信息

 

 

1.实体类ZOAGETSDTKNVP、TABLE_OF_ZOAGETSDTKNVPHolder用于对接数据

package functions.rfc.sap.document.sap_com; /** * @Author: weifengyang * @Date: 2022/2/18 10:17 */ public class ZOAGETSDTKNVP implements java.io.Serializable { private String MANDT; private String KUNNR; private String VKORG; private String VTWEG; private String KUNN1; private String KUNN2; private String SPART; public ZOAGETSDTKNVP() { } public ZOAGETSDTKNVP(String MANDT, String KUNNR, String VKORG, String VTWEG, String KUNN1, String KUNN2, String SPART) { this.MANDT = MANDT; this.KUNNR = KUNNR; this.VKORG = VKORG; this.VTWEG = VTWEG; this.KUNN1 = KUNN1; this.KUNN2 = KUNN2; this.SPART = SPART; } public String getMANDT() { return MANDT; } public void setMANDT(String MANDT) { this.MANDT = MANDT; } public String getKUNNR() { return KUNNR; } public void setKUNNR(String KUNNR) { this.KUNNR = KUNNR; } public String getVKORG() { return VKORG; } public void setVKORG(String VKORG) { this.VKORG = VKORG; } public String getVTWEG() { return VTWEG; } public void setVTWEG(String VTWEG) { this.VTWEG = VTWEG; } public String getKUNN1() { return KUNN1; } public void setKUNN1(String KUNN1) { this.KUNN1 = KUNN1; } public String getKUNN2() { return KUNN2; } public void setKUNN2(String KUNN2) { this.KUNN2 = KUNN2; } public String getSPART() { return SPART; } public void setSPART(String SPART) { this.SPART = SPART; } private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof ZOAGETSDTKNVP)) return false; ZOAGETSDTKNVP other = (ZOAGETSDTKNVP) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.MANDT ==null && other.getMANDT()==null) || (this.MANDT!=null && this.MANDT.equals(other.getMANDT()))) && ((this.KUNNR==null && other.getKUNNR()==null) || (this.KUNNR!=null && this.KUNNR.equals(other.getKUNNR())))&& ((this.VKORG==null && other.getVKORG()==null) || (this.VKORG!=null && this.VKORG.equals(other.getVKORG())))&& ((this.VTWEG==null && other.getVTWEG()==null) || (this.VTWEG!=null && this.VTWEG.equals(other.getVTWEG())))&& ((this.KUNN1==null && other.getKUNN1()==null) || (this.KUNN1!=null && this.KUNN1.equals(other.getKUNN1())))&& ((this.KUNN2==null && other.getKUNN2()==null) || (this.KUNN2!=null && this.KUNN2.equals(other.getKUNN2())))&& ((this.SPART==null && other.getSPART()==null) || (this.SPART!=null && this.SPART.equals(other.getSPART()))); __equalsCalc = null; return _equals; } private boolean __hashCodeCalc = false; public synchronized int hashCode() { if (__hashCodeCalc) { return 0; } __hashCodeCalc = true; int _hashCode = 1; if (getMANDT() != null) { _hashCode += getMANDT().hashCode(); } if (getKUNNR() != null) { _hashCode += getKUNNR().hashCode(); } if (getVKORG() != null) { _hashCode += getVKORG().hashCode(); } if (getVTWEG() != null) { _hashCode += getVTWEG().hashCode(); } if (getKUNN1() != null) { _hashCode += getKUNN1().hashCode(); } if (getKUNN2() != null) { _hashCode += getKUNN2().hashCode(); }if (getSPART() != null) { _hashCode += getSPART().hashCode(); } __hashCodeCalc = false; return _hashCode; } // Type metadata private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(ZOAGETSDTKNVP.class, true); static { typeDesc.setXmlType(new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "ZOAGETSDTKNVP")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("MANDT"); elemField.setXmlName(new javax.xml.namespace.QName("", "MANDT")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("KUNNR"); elemField.setXmlName(new javax.xml.namespace.QName("", "KUNNR")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("VKORG"); elemField.setXmlName(new javax.xml.namespace.QName("", "VKORG")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("VTWEG"); elemField.setXmlName(new javax.xml.namespace.QName("", "VTWEG")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("KUNN1"); elemField.setXmlName(new javax.xml.namespace.QName("", "KUNN1")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("KUNN2"); elemField.setXmlName(new javax.xml.namespace.QName("", "KUNN2")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("SPART"); elemField.setXmlName(new javax.xml.namespace.QName("", "SPART")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); } /** * Return type metadata object */ public static org.apache.axis.description.TypeDesc getTypeDesc() { return typeDesc; } /** * Get Custom Serializer */ public static org.apache.axis.encoding.Serializer getSerializer( java.lang.String mechType, java.lang.Class _javaType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanSerializer( _javaType, _xmlType, typeDesc); } /** * Get Custom Deserializer */ public static org.apache.axis.encoding.Deserializer getDeserializer( java.lang.String mechType, java.lang.Class _javaType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanDeserializer( _javaType, _xmlType, typeDesc); } }

/** * @Author: weifengyang * @Date: 2022/2/18 10:41 */ public class TABLE_OF_ZOAGETSDTKNVPHolder implements javax.xml.rpc.holders.Holder { public functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[] value; public TABLE_OF_ZOAGETSDTKNVPHolder() { } public TABLE_OF_ZOAGETSDTKNVPHolder(functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[] value) { this.value = value; } }

2.新建TABLE_OF_ZOAGETSDTKNVP_ProType

/** * @Author: weifengyang * @Date: 2022/2/18 10:44 */ public interface TABLE_OF_ZOAGETSDTKNVP_ProType extends java.rmi.Remote { public void TABLE_OF_ZOAGETSDTKNVP(functions.rfc.sap.document.sap_com.holders.TABLE_OF_ZOAGETSDTKNVPHolder zoagetsdtknvpHolder,java.lang.String I_KUNNR,java.lang.String I_VKORG,java.lang.String I_VTWEG, javax.xml.rpc.holders.StringHolder e_CODE, javax.xml.rpc.holders.StringHolder e_MSG) throws java.rmi.RemoteException; }

3.实现TABLE_OF_ZOAGETSDTKNVP_ProType

package functions.rfc.sap.document.sap_com; /** * @Author: weifengyang * @Date: 2022/2/18 10:43 */ public class TABLE_OF_ZOAGETSDTKNVP_BindingStub extends org.apache.axis.client.Stub implements functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType { private java.util.Vector cachedSerClasses = new java.util.Vector(); private java.util.Vector cachedSerQNames = new java.util.Vector(); private java.util.Vector cachedSerFactories = new java.util.Vector(); private java.util.Vector cachedDeserFactories = new java.util.Vector(); static org.apache.axis.description.OperationDesc [] _operations; static { _operations = new org.apache.axis.description.OperationDesc[1]; _initOperationDesc1(); } private static void _initOperationDesc1(){ org.apache.axis.description.OperationDesc oper; org.apache.axis.description.ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper.setName("ZOA_ZSDTKNVP_DISPLAY"); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "IT_DATA"), org.apache.axis.description.ParameterDesc.INOUT, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "TABLE_OF_ZOAGETSDTKNVP"), functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[].class, false, false); param.setItemQName(new javax.xml.namespace.QName("", "item")); oper.addParameter(param); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "I_KUNNR"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char10"), java.lang.String.class, false, false); oper.addParameter(param); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "I_VKORG"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char4"), java.lang.String.class, false, false); oper.addParameter(param); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "I_VTWEG"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char2"), java.lang.String.class, false, false); oper.addParameter(param); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "E_CODE"), org.apache.axis.description.ParameterDesc.OUT, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char1"), java.lang.String.class, false, false); oper.addParameter(param); param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("", "E_MSG"), org.apache.axis.description.ParameterDesc.OUT, new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char100"), java.lang.String.class, false, false); oper.addParameter(param); oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID); oper.setStyle(org.apache.axis.constants.Style.WRAPPED); oper.setUse(org.apache.axis.constants.Use.LITERAL); _operations[0] = oper; } public TABLE_OF_ZOAGETSDTKNVP_BindingStub() throws org.apache.axis.AxisFault { this(null); } public TABLE_OF_ZOAGETSDTKNVP_BindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { this(service); super.cachedEndpoint = endpointURL; } public TABLE_OF_ZOAGETSDTKNVP_BindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { if (service == null) { super.service = new org.apache.axis.client.Service(); } else { super.service = service; } ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2"); java.lang.Class cls; javax.xml.namespace.QName qName; javax.xml.namespace.QName qName2; java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char1"); cachedSerQNames.add(qName); cls = java.lang.String.class; cachedSerClasses.add(cls); cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName)); cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName)); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char100"); cachedSerQNames.add(qName); cls = java.lang.String.class; cachedSerClasses.add(cls); cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName)); cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName)); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char10"); cachedSerQNames.add(qName); cls = java.lang.String.class; cachedSerClasses.add(cls); cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName)); cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName)); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char4"); cachedSerQNames.add(qName); cls = java.lang.String.class; cachedSerClasses.add(cls); cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName)); cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName)); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "char2"); cachedSerQNames.add(qName); cls = java.lang.String.class; cachedSerClasses.add(cls); cachedSerFactories.add(org.apache.axis.encoding.ser.BaseSerializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleSerializerFactory.class, cls, qName)); cachedDeserFactories.add(org.apache.axis.encoding.ser.BaseDeserializerFactory.createFactory(org.apache.axis.encoding.ser.SimpleDeserializerFactory.class, cls, qName)); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "TABLE_OF_ZOAGETSDTKNVP"); cachedSerQNames.add(qName); cls = functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[].class; cachedSerClasses.add(cls); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "ZOAGETSDTKNVP"); qName2 = new javax.xml.namespace.QName("", "item"); cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2)); cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory()); qName = new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "ZOAGETSDTKNVP"); cachedSerQNames.add(qName); cls = functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP.class; cachedSerClasses.add(cls); cachedSerFactories.add(beansf); cachedDeserFactories.add(beandf); } protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { try { org.apache.axis.client.Call _call = super._createCall(); if (super.maintainSessionSet) { _call.setMaintainSession(super.maintainSession); } if (super.cachedUsername != null) { _call.setUsername(super.cachedUsername); } if (super.cachedPassword != null) { _call.setPassword(super.cachedPassword); } if (super.cachedEndpoint != null) { _call.setTargetEndpointAddress(super.cachedEndpoint); } if (super.cachedTimeout != null) { _call.setTimeout(super.cachedTimeout); } if (super.cachedPortName != null) { _call.setPortName(super.cachedPortName); } java.util.Enumeration keys = super.cachedProperties.keys(); while (keys.hasMoreElements()) { java.lang.String key = (java.lang.String) keys.nextElement(); _call.setProperty(key, super.cachedProperties.get(key)); } synchronized (this) { if (firstCall()) { // must set encoding style before registering serializers _call.setEncodingStyle(null); for (int i = 0; i < cachedSerFactories.size(); ++i) { java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames.get(i); java.lang.Object x = cachedSerFactories.get(i); if (x instanceof Class) { java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); _call.registerTypeMapping(cls, qName, sf, df, false); } else if (x instanceof javax.xml.rpc.encoding.SerializerFactory) { org.apache.axis.encoding.SerializerFactory sf = (org.apache.axis.encoding.SerializerFactory) cachedSerFactories.get(i); org.apache.axis.encoding.DeserializerFactory df = (org.apache.axis.encoding.DeserializerFactory) cachedDeserFactories.get(i); _call.registerTypeMapping(cls, qName, sf, df, false); } } } } return _call; } catch (java.lang.Throwable _t) { throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); } } public void TABLE_OF_ZOAGETSDTKNVP(functions.rfc.sap.document.sap_com.holders.TABLE_OF_ZOAGETSDTKNVPHolder OUTDATA, java.lang.String KUNNR,java.lang.String VKORG,java.lang.String VTWEG,javax.xml.rpc.holders.StringHolder e_CODE, javax.xml.rpc.holders.StringHolder e_MSG) throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { throw new org.apache.axis.NoEndPointException(); } org.apache.axis.client.Call _call = createCall(); _call.setOperation(_operations[0]); _call.setUseSOAPAction(true); _call.setSOAPActionURI("urn:sap-com:document:sap:rfc:functions:ZOA_ZSDTKNVP_DISPLAY:ZOA_ZSDTKNVP_DISPLAYRequest"); _call.setEncodingStyle(null); _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); _call.setOperationName(new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "ZOA_ZSDTKNVP_DISPLAY")); setRequestHeaders(_call); setAttachments(_call); try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {OUTDATA.value,KUNNR,VKORG,VTWEG}); if (_resp instanceof java.rmi.RemoteException) { throw (java.rmi.RemoteException)_resp; } else { extractAttachments(_call); java.util.Map _output; _output = _call.getOutputParams(); try { OUTDATA.value = (functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[]) _output.get(new javax.xml.namespace.QName("", "IT_DATA")); } catch (java.lang.Exception _exception) { OUTDATA.value = (functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[]) org.apache.axis.utils.JavaUtils.convert(_output.get(new javax.xml.namespace.QName("", "IT_DATA")), functions.rfc.sap.document.sap_com.ZOAGETSDTKNVP[].class); } try { e_CODE.value = (java.lang.String) _output.get(new javax.xml.namespace.QName("", "E_CODE")); } catch (java.lang.Exception _exception) { e_CODE.value = (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_output.get(new javax.xml.namespace.QName("", "E_CODE")), java.lang.String.class); } try { e_MSG.value = (java.lang.String) _output.get(new javax.xml.namespace.QName("", "E_MSG")); } catch (java.lang.Exception _exception) { e_MSG.value = (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_output.get(new javax.xml.namespace.QName("", "E_MSG")), java.lang.String.class); } } } catch (org.apache.axis.AxisFault axisFaultException) { throw axisFaultException; } } }

4.新建TABLE_OF_ZOAGETSDTKNVP_Service

/** * @Author: weifengyang * @Date: 2022/2/18 11:22 */ public interface TABLE_OF_ZOAGETSDTKNVP_Service extends javax.xml.rpc.Service { public java.lang.String getTABLE_OF_ZOAGETSDTKNVPAddress(); public functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType getTABLE_OF_ZOAGETSDTKNVP() throws javax.xml.rpc.ServiceException; public functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType getTABLE_OF_ZOAGETSDTKNVP(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; }

5.新建TABLE_OF_ZOAGETSDTKNVP_ServiceLocator

/** * @Author: weifengyang * @Date: 2022/2/18 11:21 */ public class TABLE_OF_ZOAGETSDTKNVP_ServiceLocator extends org.apache.axis.client.Service implements functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_Service { public TABLE_OF_ZOAGETSDTKNVP_ServiceLocator() { } public TABLE_OF_ZOAGETSDTKNVP_ServiceLocator(org.apache.axis.EngineConfiguration config) { super(config); } public TABLE_OF_ZOAGETSDTKNVP_ServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException { super(wsdlLoc, sName); } // Use to get a proxy class for TABLE_OF_ZOAGETSDTKNVP private java.lang.String TABLE_OF_ZOAGETSDTKNVP_address = "http://sapdevapp.ectsz.com:8000/sap/bc/srt/rfc/sap/ZOA_ZSDTKNVP_DISPLAY/600/ZOA_ZSDTKNVP_DISPLAY/ZOA_ZSDTKNVP_DISPLAY"; public java.lang.String getTABLE_OF_ZOAGETSDTKNVPAddress() { return TABLE_OF_ZOAGETSDTKNVP_address; } // The WSDD service name defaults to the port name. private java.lang.String TABLE_OF_ZOAGETSDTKNVPWSDDServiceName = "TABLE_OF_ZOAGETSDTKNVP"; public java.lang.String getTABLE_OF_ZOAGETSDTKNVPWSDDServiceName() { return TABLE_OF_ZOAGETSDTKNVPWSDDServiceName; } public void setTABLE_OF_ZOAGETSDTKNVPWSDDServiceName(java.lang.String name) { TABLE_OF_ZOAGETSDTKNVPWSDDServiceName = name; } public functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType getTABLE_OF_ZOAGETSDTKNVP() throws javax.xml.rpc.ServiceException { java.net.URL endpoint; try { endpoint = new java.net.URL(TABLE_OF_ZOAGETSDTKNVP_address); } catch (java.net.MalformedURLException e) { throw new javax.xml.rpc.ServiceException(e); } return getTABLE_OF_ZOAGETSDTKNVP(endpoint); } public functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType getTABLE_OF_ZOAGETSDTKNVP(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { try { functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_BindingStub _stub = new functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_BindingStub(portAddress, this); _stub.setPortName(getTABLE_OF_ZOAGETSDTKNVPWSDDServiceName()); return _stub; } catch (org.apache.axis.AxisFault e) { return null; } } public void setTABLE_OF_ZOAGETSDTKNVPEndpointAddress(java.lang.String address) { TABLE_OF_ZOAGETSDTKNVP_address = address; } /** * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { try { if (functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_ProType.class.isAssignableFrom(serviceEndpointInterface)) { functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_BindingStub _stub = new functions.rfc.sap.document.sap_com.TABLE_OF_ZOAGETSDTKNVP_BindingStub(new java.net.URL(TABLE_OF_ZOAGETSDTKNVP_address), this); _stub.setPortName(getTABLE_OF_ZOAGETSDTKNVPWSDDServiceName()); return _stub; } } catch (java.lang.Throwable t) { throw new javax.xml.rpc.ServiceException(t); } throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); } /** * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown. */ public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { if (portName == null) { return getPort(serviceEndpointInterface); } java.lang.String inputPortName = portName.getLocalPart(); if ("TABLE_OF_ZOAGETSDTKNVP".equals(inputPortName)) { return getTABLE_OF_ZOAGETSDTKNVP(); } else { java.rmi.Remote _stub = getPort(serviceEndpointInterface); ((org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; } } public javax.xml.namespace.QName getServiceName() { return new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "TABLE_OF_ZOAGETSDTKNVP"); } private java.util.HashSet ports = null; public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); ports.add(new javax.xml.namespace.QName("urn:sap-com:document:sap:rfc:functions", "TABLE_OF_ZOAGETSDTKNVP")); } return ports.iterator(); } /** * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { if ("TABLE_OF_ZOAGETSDTKNVP".equals(portName)) { setTABLE_OF_ZOAGETSDTKNVPEndpointAddress(address); } else { // Unknown Port Name throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); } } /** * Set the endpoint address for the specified port name. */ public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { setEndpointAddress(portName.getLocalPart(), address); } }

6.调用接口service类ZOA_ZSDTKNVP_MODIFYQueryService

package ectsz.sd; import functions.rfc.sap.document.sap_com.*; import functions.rfc.sap.document.sap_com.holders.TABLE_OF_ZOAGETSDTKNVPHolder; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.log4j.Logger; import weaver.general.BaseBean; import ws.log.LoggerUtil; import javax.xml.rpc.holders.StringHolder; import java.net.URL; /** * @Author: weifengyang * @Date: 2022/2/18 11:11 */ public class TABLE_OF_ZOAGETSDTKNVPQueryService { private Logger logger = null; public TABLE_OF_ZOAGETSDTKNVPQueryService() { this(false); } public TABLE_OF_ZOAGETSDTKNVPQueryService(Boolean isUnitTest) { logger = LoggerUtil.getLogger(1, "客户-销售员-产品组关联关系查询", isUnitTest); // logger.info("class: " + TABLE_OF_ZOAGETSDTKNVPQueryService.class.getName()); } public JSONObject callSAP(String KUNNR, String VKORG, String VTWEG) { JSONObject sapResult = new JSONObject(); try { // 获取sap ws相关信息 String sapUsername = new BaseBean().getPropValue("ect", "sapws.username"); String sapPassword = new BaseBean().getPropValue("ect", "sapws.password"); String sapServer = new BaseBean().getPropValue("ect", "sapws.server"); String sapUrl = sapServer + new BaseBean().getPropValue("ect", "sapws.url.ZOA_ZSDTKNVP_DISPLAY"); logger.info("sap接口地址:" + sapUrl); URL url = new URL(sapUrl); TABLE_OF_ZOAGETSDTKNVP_ServiceLocator locator = new TABLE_OF_ZOAGETSDTKNVP_ServiceLocator(); TABLE_OF_ZOAGETSDTKNVP_BindingStub stub = new TABLE_OF_ZOAGETSDTKNVP_BindingStub(url, locator); stub.setUsername(sapUsername); stub.setPassword(sapPassword); String I_KUNNR = KUNNR; String I_VKORG = VKORG; String I_VTWEG = VTWEG; // logger.info("===SAP输入参数==="); // logger.info("I_KUNNR:" + I_KUNNR); // logger.info("I_VKORG:" + I_VKORG); // logger.info("I_VTWEG:" + I_VTWEG); // 输出参数初始化 StringHolder e_CODE = new StringHolder(), e_MSG = new StringHolder(); e_CODE.value = ""; e_MSG.value = ""; TABLE_OF_ZOAGETSDTKNVPHolder IT_DATA = new TABLE_OF_ZOAGETSDTKNVPHolder(); // 调用sap接口 stub.TABLE_OF_ZOAGETSDTKNVP(IT_DATA, I_KUNNR, I_VKORG, I_VTWEG, e_CODE, e_MSG); String code = e_CODE.value; String msg = e_MSG.value; // 打印输出SAP返回结果 sapResult.put("CODE", code); sapResult.put("MSG", msg); ZOAGETSDTKNVP[] etData = IT_DATA.value; JSONArray sapResultData = JSONArray.fromObject(etData); sapResult.put("DATA", sapResultData); // logger.info("===SAP返回结果==="); // logger.info(sapResult.toString()); if ("E".equals(code)) { LoggerUtil.endFailure(); } else if ("S".equals(e_CODE.value)) { LoggerUtil.endSuccess(); } } catch (Exception e) { LoggerUtil.endFailure(e); } return sapResult; } }

7.接口调用TABLE_OF_ZOAGETSDTKNVPAction

package com.api.ect.sd; import ectsz.sd.SellingDailyReportService; import ectsz.sd.TABLE_OF_ZOAGETSDTKNVPQueryService; import net.sf.json.JSONObject; import weaver.general.Util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; /** * @Author: weifengyang * @Date: 2022/2/18 11:05 */ @Path("/ectsz/customer") public class TABLE_OF_ZOAGETSDTKNVPAction { @GET @Path("/get_customer_xsy_cpz_info") @Produces(MediaType.TEXT_PLAIN) public String dailySearch(@Context HttpServletRequest request, @Context HttpServletResponse response) { String KUNNR = Util.null2String(request.getParameter("I_KUNNR")); String VKORG = Util.null2String(request.getParameter("I_VKORG")); String VTWEG = Util.null2String(request.getParameter("I_VTWEG")); TABLE_OF_ZOAGETSDTKNVPQueryService service = new TABLE_OF_ZOAGETSDTKNVPQueryService(false); JSONObject jsonObject = service.callSAP(KUNNR, VKORG, VTWEG); return jsonObject.toString(); } } 后台代码编写完成,接着回到前端调用......

测试调用结果

 OA前端写JS调用

 

  $(function(){ //分销渠道值改变触发事件 WfForm.bindFieldChangeEvent("field19525", function(obj,id,value){   var field = value ;   if(field != ""){   callsap(field);   }else{     alert("无数据。。");     WfForm.delDetailRow("detail_1", "all");   } });      //调用接口将客户、销售组织、分销渠道的值传给SAP function callsap(field){    //获取客户,销售组织的值   var value1 = WfForm.getFieldValue("field19523");   var value2 = WfForm.getBrowserShowName("field19529");   console.log("value1-",value1);   console.log("value2-",value2);   window.ecCom.WeaTools.callApi('/api/ectsz/customer/get_customer_xsy_cpz_info','GET',{     I_VTWEG:field,     I_KUNNR:value1,     I_VKORG:value2   }, 'json', false, false).then(function(result){     var  obj = result.DATA;     //调用接口成功,SAP返回销售员,终端客户,产品组的值。     if(result.CODE == 'S'){       for(var i=0;i



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3