连接到 Magento SOAP API java

问题描述 投票:0回答:1

我正在尝试连接到java中的magentosoapapi,我已经根据错误日志添加了几乎所有jar文件,但是我陷入了这个运行时异常,请看一下代码和输出.

import com.google.code.magja.soap.MagentoSoapClient;
import com.google.code.magja.soap.SoapConfig;
import org.apache.axis2.AxisFault;


public class testConnection {
    public static void main(String[] args) throws AxisFault {
        String user = "XXXXXX";
        String pass = "XXXXX";
        String host = "http://XXX.co.in/magento/index.php/api/soap?wsdl";
        SoapConfig soapConfig = new SoapConfig(user, pass, host);
        MagentoSoapClient magentoSoapClient = MagentoSoapClient.getInstance(soapConfig);
        // configure connection        
        magentoSoapClient.setConfig(soapConfig);

    }
}

输出

Exception in thread "main" java.lang.RuntimeException: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
    at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:56)
    at com.google.code.magja.soap.MagentoSoapClient.getInstance(MagentoSoapClient.java:79)
    at magentomanager.testConnection.main(testConnection.java:14)
Caused by: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
    at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:708)
    at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:122)
    at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:857)
    at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
    at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:151)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:144)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:251)
    at com.google.code.magja.soap.MagentoSoapClient.login(MagentoSoapClient.java:138)
    at com.google.code.magja.soap.MagentoSoapClient.<init>(MagentoSoapClient.java:53)
    ... 2 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.transport.http.CommonsHTTPTransportSender
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at org.apache.axis2.util.Loader.loadClass(Loader.java:261)
    at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:683)

添加了 JAR 文件

enter image description here

java magento soap magento-soap-api
1个回答
2
投票

我刚刚遇到了同样的问题,并将这些依赖项添加到我的 Maven pom 中

<dependency>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-transport-http</artifactId>
    <version>1.6.2</version>
</dependency>

<dependency>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-transport-local</artifactId>
    <version>1.6.2</version>
</dependency>

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.