2

我需要在 Lotus Notes 6.5 DB 中编写 JavaAgent 来访问 Web 服务。为此,我使用了 Axis Apache API。我创建了一个 Java 代理,并使用编辑项目按钮在代理中添加了轴的 jar 文件。

下面是代理代码:

import lotus.domino.*;
import javax.xml.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.net.URL;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

        try {


            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            String  endpoint = "http://ws.apache.org:5049/axis/services/echo";
            Service service = new Service();
            Call     call    = (Call) service.createCall();
            call.setTargetEndpointAddress(new java.net.URL(endpoint) );

            call.setOperationName(new QName("http://soapinterop.org/", "echoString"));
            String ret = (String) call.invoke( new Object[] { "Hello!" } );
            System.out.println("Sent 'Hello!', got '" + ret + "'");

        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

下面是抛出的异常:

java.lang.ExceptionInInitializerError: org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory

    at org.apache.commons.discovery.tools.SPInterface.newInstance(SPInterface.java:197)

    at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:579)

    at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:418)

    at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378)

    at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:84)

    at java.security.AccessController.doPrivileged(Native Method)

    at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:80)

    at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:72)

    at org.apache.axis.configuration.EngineConfigurationFactoryFinder.<clinit>(EngineConfigurationFactoryFinder.java:94)

    at org.apache.axis.client.Service.<init>(Service.java:111)

    at JavaAgent.NotesMain(JavaAgent.java:17)

    at lotus.domino.AgentBase.runNotes(Unknown Source)

    at lotus.domino.NotesThread.run(NotesThread.java:218)

我试着在互联网上关注一些链接,比如,但我无法准确地得到它要求做的事情。例如:http ://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/40d033fba3897f4d85256cd30034026a?OpenDocument

任何帮助都会很棒。我想做的就是编写一个代理,以便我可以访问 Web 服务,比如 w3schools 上的温度转换 Web 服务。http://www.w3schools.com/webservices/tempconvert.asmx?op=FahrenheitToCelsius

4

1 回答 1

3

我用你的错误信息用谷歌搜索,这是第一个命中:

http://croarkin.blogspot.fi/2010/08/commons-logging-headaches-with-axis.html

它建议使用commons-logging.properties文件:

org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger  
org.apache.commons.logging.LogFactory = org.apache.commons.logging.impl.LogFactoryImpl

或将其放入您的代码中:

@BeforeClass  
public static void beforeClass() {  
 System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");  
 System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");  
}

可能您已经尝试过这个,因为它是谷歌的第一个热门,但以防万一......

于 2012-11-30T09:37:50.670 回答