Web服务方法调用一次,但执行多次

时间:2015-07-06 16:16:07

标签: java web-services soap

我在Java EE 6中开发一个Web服务,只有一个名为E1CreateAccount的方法。

对于我对方法执行的每次调用,都会发生方法的执行多次(至少2次)。执行是连续的,所以下一个开始时前一个结束。

该方法的代码如下:

@WebMethod
public Object E1CreateAccount(@WebParam(name = "arg0") InboundAccountF56101IB newAccount) {
    Object ret = "KO";
    MyAction action = MyAction.CREATE;
    MyLogger.getLogger().info("Integration WebService called to Create new Account in E1, name " +
            newAccount.getCRMAccountName());
    E1AccountClientThread runner = new E1AccountClientThread();
    runner.initialize(newAccount, action);
    Thread thread = new Thread(runner);
    MyLogger.getLogger().info(thread.getId() + ": Created thread to " + action.name() +
            " Account. Account Name: " + newAccount.getCRMAccountName() + "...");
    try {
        MyLogger.getLogger().info(thread.getId() +
                ": Starting thread to call E1 Account web service, Action: " +
                action.name());
        thread.start();
        ret = "OK";
    } catch(Exception e) {
        String str = "Exception calling the thread delegate to call E1 Account web service (Action " +
                action.name() + ". Message: " + e.getMessage().toString();
        MyLogger.getLogger().severe(str);
        ret="KO " + str;
    }
    return ret;
}

它接收调用,它记录已调用服务的事实,然后创建一个将执行该任务的独立线程。然后它总是返回字符串" OK"。

该方法效果很好,唯一的问题是多次执行,这对软件来说是不可取的。

这是我从日志中看到的:

Jul 06, 2015 3:17:57 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: Integration WebService called to Create new Account in E1, name THIS_IS_THE_COMPANY_NAME
Jul 06, 2015 3:17:57 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: 1026: Created thread to CREATE Account. Account Name: THIS_IS_THE_COMPANY_NAME...
Jul 06, 2015 3:17:57 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: 1026: Starting thread to call E1 Account web service, Action: CREATE
[...]
Jul 06, 2015 3:18:00 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: Integration WebService called to Create new Account in E1, name THIS_IS_THE_COMPANY_NAME
Jul 06, 2015 3:18:00 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: 1027: Created thread to CREATE Account. Account Name: THIS_IS_THE_COMPANY_NAME...
Jul 06, 2015 3:18:00 PM integration.services.e1.account.E1AccountService E1CreateAccount
INFO: 1027: Starting thread to call E1 Account web service, Action: CREATE
[...]

(我用[...]替换了与线程实际相关的日志,因为我觉得它不相关)

Web服务已部署在WebLogic 12.1.3上,我使用了ide JDeveloper 12.1.3

0 个答案:

没有答案