我在 Eclipse for Mac 中有一个 java web 服务,使用 JCo 连接器访问多个 RFC,但我的 java 代码无法访问 SAP,出现错误“(102) JCO_ERROR_COMMUNICATION: 连接到 SAP 网关失败”,但我通过添加要访问的服务器的 IP、mac os x 的文件主机解决了这个问题。问题是,当您在 Mac Os X 服务器上访问此 Web 服务时,返回错误“hostname.private”,并且我无法访问 SAP。
JCo 异常(exception):
com.sap.conn.jco.JCoException:
(102) JCO_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS ASHOST=192.168.90.5 SYSNR=04 SAPROUTER=/H/192.220.35.89/S/3299 PCS=1
LOCATION CPIC (TCP/IP) on local host
ERROR hostname 'servermac.private' unknown
TIME Mon Jul 4 13:18:36 2011
RELEASE 720
COMPONENT NI (network interface)
VERSION 40
RC -2
MODULE nixxhl.cpp
LINE 183
DETAIL NiHLGetNodeAddr: hostname cached as unknown
COUNTER 4 here
网络服务错误:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.reflect.InvocationTargetException</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">servermac.private</ns1:hostname>
</detail>
</soapenv:Fault>
最佳答案
当我用要连接的服务器的IP编辑hosts文件时,可以有效地连接 SAP,但是错误出在 WSDL 上,这并不是特别的,而是我的 Web 服务已导出到 WAR 并在不同的服务器上使用它无法连接,因为库找不到 JCo 的 libsapjco3.jnilib,因此给了我主机无法连接的错误。
然后在项目 agrege 的 Properties->DeploymentAssembly 部分中添加 sapjco3.jar 并在 lib 部分的外部项目中添加库 libsapjco3.jnilib,效果良好。
关于java - 如何从 Java Web 服务访问 SAP JCo 连接器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6576661/