调用JCO连接SAP的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调用JCO连接SAP的问题相关的知识,希望对你有一定的参考价值。

首先我用java直接调用 跑main是没问题的。当时当我部署j2ee上的时候出现了类无法找到的情况,实在是费解。

提示出错的地方是:JCO.Client sapConnection = JCO.createClient(端口号, 用户名, 密码, 语言, 服务器IP地址, 系统编号);
提示出错的原因是:Caused by: java.lang.NoClassDefFoundError: com/sap/mw/jco/JCO
但是我这个包里面是有这个类的啊,懊恼啊,请高手帮忙,小弟先谢过,附上页面上的错误信息:
[2011-07-30 15:15:26] main java.lang.NoClassDefFoundError: com/sap/mw/jco/JCO
at com.sitc.fin.sap.SapBusiness.login(SapBusiness.java:26)
at com.sitc.fin.sap.SapBusiness.setReport(SapBusiness.java:46)
at com.sitc.fin.sap.JcoTest.testSend(JcoTest.java:81)
at com.sitc.fin.rcp.viewpart.FindVoucherView.doBtnChangeRateAction(FindVoucherView.java:486)
at com.sitc.fin.rcp.viewpart.FindVoucherView$8.widgetSelected(FindVoucherView.java:419)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.gemship.commondata.rcp.CommonDataApplication.start(CommonDataApplication.java:28)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

参考技术A 这种问题,建议发到SDN或者ITTOOLBOX上去。 参考技术B 这个问题建议你找专业人士问问,查阅相关资料。

Android 和 SAP SOAP Web 服务之间的连接建立

【中文标题】Android 和 SAP SOAP Web 服务之间的连接建立【英文标题】:Connection Establishment between Android and SAP SOAP Webservices 【发布时间】:2012-04-23 05:50:00 【问题描述】:

我想从 android 应用程序连接 SAP SOAP Web 服务,我正在使用以下代码,但出现异常。当我调试代码时,调用方法 id 未执行。我正在使用 URL 中附加的用户名和密码。

package com.veee.pack;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.os.Bundle;

public class WeservicesExampleActivity extends Activity 
       @Override
    public void onCreate(Bundle savedInstanceState) 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
             final String METHOD_NAME = "Z_CUSTOMER_LOOKUP1";
         final String SOAP_ACTION = "http://********************:8000/sap/bc/srt/rfc/sap/z_customer_lookup1/800/z_customer_lookup1/z_customer_lookup1_bind/Z_CUSTOMER_LOOKUP1";
         final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
         final String URL = "http://******************:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=***************&sap-password=************";

//here i made the request

            SoapObject request =new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("Input", "1460");


        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);

        AndroidHttpTransport httpTransport=new AndroidHttpTransport(URL);
      httpTransport.debug = true;
      try 
  //here call the services method.
            httpTransport.call(SOAP_ACTION, envelope);

//calling the services 

        SoapPrimitive result = (SoapPrimitive) envelope.getResponse();


        System.out.println("Result" + result.toString());
     catch (IOException e) 
        // TODO Auto-generated catch block
        e.printStackTrace();
     catch (XmlPullParserException e) 
        // TODO Auto-generated catch block
        e.printStackTrace();
    
       

       
 I got the following  Exception

04-23 10:50:04.744: WARN/System.err(442): org.xmlpull.v1.XmlPullParserException: expected: START_TAG http://schemas.xmlsoap.org/soap/envelope/Envelope (position:START_TAG <http://schemas.xmlsoap.org/wsdl/wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@40546f50)

请帮助我克服这个异常,我尝试了一些使用 i ksop2 的示例得到了成功输出。

【问题讨论】:

I (pronoun) 【参考方案1】:

嗨,Venkatasubbaiah Atluru,

您在 URL 中传递参数类似于 http://abc.com/xyz/api/sap-client=800&sap-user=******&sap -password=*****"

但是在请求中传递参数, 比如 request.addProperty("sap-client", "800"); request.addProperty("sap-user", "*"); request.addProperty("sap-password", "*");

你的问题会解决的......

如果您有任何疑问,请告诉我......

享受编程……

【讨论】:

以上是关于调用JCO连接SAP的问题的主要内容,如果未能解决你的问题,请参考以下文章

在 GlassFish v2.1 中永久加载的 SAP JCo 连接器(无法卸载)

SAP R3和JAVA交换数据之JCO

java程序无法远程调用sap函数

JCo for SAP中的嵌套结构?

JCO重连SAP

如何使用RFC在JCO表中设置多个数据?