Так же рекомендую обратить внимание на
следующую темуВ таком случае добавится интерфейс
Код:
package api.ru.test.bgbilling.test.impl.common;
import javax.jws.WebParam;
import javax.jws.WebService;
/**
* @author SinTeZ
*/
@WebService
public interface TestService {
Integer createContract(@WebParam(name = "contractPatternId", targetNamespace = "http://test.bgbilling.ru") int contractPatternId);
}
Сервис поменяется на
Код:
package api.ru.test.bgbilling.test.impl;
import api.ru.test.bgbilling.test.impl.common.TestService;
import bitel.billing.server.contract.bean.ContractManager;
import org.apache.log4j.Logger;
import ru.bitel.bgbilling.common.BGException;
import ru.bitel.bgbilling.kernel.container.service.server.AbstractService;
import ru.bitel.bgbilling.server.util.ServerUtils;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import java.sql.Connection;
import java.util.Calendar;
@WebService(name = "TestService",
targetNamespace = "http://test.bgbilling.ru/",
serviceName = "TestService",
endpointInterface = "api.ru.test.bgbilling.test.impl.common.TestService")
public class TestServiceImpl extends AbstractService implements TestService {
private static final Logger logger = Logger.getLogger(TestServiceImpl.class);
private Connection con;
public TestServiceImpl() {
}
@PostConstruct
protected void init() throws BGException {
logger.info("Init");
this.con = getConnection();
}
@PreDestroy
private void destroy() {
logger.info("Destroy");
if (this.con != null) {
ServerUtils.commitConnection(this.con);
ServerUtils.closeConnection(this.con);
}
}
@WebMethod(operationName = "CreateContract", action = "http://test.bgbilling.ru/createContract")
@WebResult(name = "CreateContract", targetNamespace = "http://test.bgbilling.ru/")
public Integer createContract(@WebParam(name = "contractPatternId", targetNamespace = "http://test.bgbilling.ru") int contractPatternId) {
try (ContractManager contractManager = new ContractManager(this.con)) {
return contractManager.createFromPattern(contractPatternId, null, Calendar.getInstance(), "").getId();
} catch (Exception e) {
return null;
}
}
}
А в конфиг сервера добавится строка
Код:
dynservice:test.TestService=api.ru.test.bgbilling.test.impl.TestServiceImpl
И можно будет вызвать через http(s)