use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-business-process by wso2.
the class AxisServiceUtils method invokeService.
public static void invokeService(BPELMessageContext partnerInvocationContext, ConfigurationContext configContext) throws AxisFault {
MessageContext mctx = partnerInvocationContext.getInMessageContext();
OperationClient opClient = getOperationClient(partnerInvocationContext, configContext);
mctx.getOptions().setParent(opClient.getOptions());
/*
Else we assume that the epr is not changed by the process.
In this case there's a limitation we cannot invoke the epr in the wsdl
(by assingning that epr by partnerlink assign) if there is a endpoint
configuration available for that particular service
*/
addCustomHeadersToMessageContext(mctx);
opClient.addMessageContext(mctx);
Options operationOptions = opClient.getOptions();
if (partnerInvocationContext.getUep().isAddressingEnabled()) {
// Currently we set the action manually, but this should be handled by
// addressing module it-self?
String action = getAction(partnerInvocationContext);
if (log.isDebugEnabled()) {
log.debug("Soap action: " + action);
}
operationOptions.setAction(action);
// TODO set replyto as well
// operationOptions.setReplyTo(mctx.getReplyTo());
}
if (partnerInvocationContext.getUep().getAddress() == null) {
partnerInvocationContext.getUep().setAddress(getEPRfromWSDL(partnerInvocationContext.getBpelServiceWSDLDefinition(), partnerInvocationContext.getService(), partnerInvocationContext.getPort()));
}
operationOptions.setTo(partnerInvocationContext.getUep());
opClient.execute(true);
if (partnerInvocationContext.isTwoWay()) {
partnerInvocationContext.setOutMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
partnerInvocationContext.setFaultMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE));
}
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-business-process by wso2.
the class BPELServerImpl method initProcessStore.
/**
* Initialize process store/
*
* @param eprContext Endpoint reference context
* @throws Exception if process store initialization failed
*/
private void initProcessStore(EndpointReferenceContext eprContext) throws Exception {
processStore = new ProcessStoreImpl(eprContext, db.getDataSource(), odeConfigurationProperties);
processStore.setLocalBPELDeploymentUnitRepo(new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "bpel"));
processStore.registerListener(new ProcessStoreListenerImpl());
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-business-process by wso2.
the class ProcessConfigurationImpl method readPackageConfiguration.
private void readPackageConfiguration() {
File depDir = du.getDeployDir();
/*
Read Endpoint Config for invokes
*/
List<TDeployment.Process> processList = du.getDeploymentDescriptor().getDeploy().getProcessList();
for (TDeployment.Process process : processList) {
List<TInvoke> tInvokeList = process.getInvokeList();
for (TInvoke tInvoke : tInvokeList) {
OMElement serviceEle;
if (tInvoke.getService() == null) {
String errMsg = "Service element missing for the invoke element in deploy.xml";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
try {
serviceEle = AXIOMUtil.stringToOM(tInvoke.getService().toString());
OMElement endpointEle = serviceEle.getFirstElement();
if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
continue;
}
EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
epConf.setServiceName(tInvoke.getService().getName().getLocalPart());
epConf.setServiceNS(tInvoke.getService().getName().getNamespaceURI());
epConf.setServicePort(tInvoke.getService().getPort());
bpelPackageConfiguration.addEndpoint(epConf);
} catch (XMLStreamException e) {
log.warn("Error occurred while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tInvoke.getService());
}
}
List<TProvide> tProvideList = process.getProvideList();
for (TProvide tProvide : tProvideList) {
OMElement serviceEle;
if (tProvide.getService() == null) {
String errMsg = "Service element missing for the provide element in deploy.xml";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
try {
serviceEle = AXIOMUtil.stringToOM(tProvide.getService().toString());
OMElement endpointEle = serviceEle.getFirstElement();
if (endpointEle == null || !endpointEle.getQName().equals(new QName(BusinessProcessConstants.BPEL_PKG_ENDPOINT_CONFIG_NS, BusinessProcessConstants.ENDPOINT))) {
continue;
}
EndpointConfiguration epConf = EndpointConfigBuilder.buildEndpointConfiguration(endpointEle, depDir.getAbsolutePath());
epConf.setServiceName(tProvide.getService().getName().getLocalPart());
epConf.setServiceNS(tProvide.getService().getName().getNamespaceURI());
epConf.setServicePort(tProvide.getService().getPort());
bpelPackageConfiguration.addEndpoint(epConf);
} catch (XMLStreamException e) {
log.warn("Error occured while reading endpoint configuration. " + "Endpoint config will not be applied to: " + tProvide.getService());
}
}
}
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method fillPartnerLinks.
// private java.lang.String[] getServiceLocationForProcess(QName processId)
// throws ProcessManagementException {
// AxisConfiguration axisConf = getConfigContext().getAxisConfiguration();
// Map<String, AxisService> services = axisConf.getServices();
// ArrayList<String> serviceEPRs = new ArrayList<String>();
//
// for (AxisService service : services.values()) {
// Parameter pIdParam = service.getParameter(BPELConstants.PROCESS_ID);
// if (pIdParam != null) {
// if (pIdParam.getValue().equals(processId)) {
// serviceEPRs.addAll(Arrays.asList(service.getEPRs()));
// }
// }
// }
//
// if (serviceEPRs.size() > 0) {
// return serviceEPRs.toArray(new String[serviceEPRs.size()]);
// }
//
// String errMsg = "Cannot find service for process: " + processId;
// log.error(errMsg);
// throw new ProcessManagementException(errMsg);
// }
private void fillPartnerLinks(ProcessInfoType pInfo, TDeployment.Process processInfo) throws ProcessManagementException {
if (processInfo.getProvideList() != null) {
EndpointReferencesType eprsType = new EndpointReferencesType();
for (TProvide provide : processInfo.getProvideList()) {
String plinkName = provide.getPartnerLink();
TService service = provide.getService();
/* NOTE:Service cannot be null for provider partner link*/
if (service == null) {
String errorMsg = "Error in <provide> element for process " + processInfo.getName() + " partnerlink" + plinkName + " did not identify an endpoint";
log.error(errorMsg);
throw new ProcessManagementException(errorMsg);
}
if (log.isDebugEnabled()) {
log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
}
QName serviceName = service.getName();
EndpointRef_type0 eprType = new EndpointRef_type0();
eprType.setPartnerLink(plinkName);
eprType.setService(serviceName);
ServiceLocation sLocation = new ServiceLocation();
try {
String url = Utils.getTryitURL(serviceName.getLocalPart(), getConfigContext());
sLocation.addServiceLocation(url);
String[] wsdls = Utils.getWsdlInformation(serviceName.getLocalPart(), getConfigContext().getAxisConfiguration());
if (wsdls.length == 2) {
if (wsdls[0].endsWith("?wsdl")) {
sLocation.addServiceLocation(wsdls[0]);
} else {
sLocation.addServiceLocation(wsdls[1]);
}
}
} catch (AxisFault axisFault) {
String errMsg = "Error while getting try-it url for the service: " + serviceName;
log.error(errMsg, axisFault);
throw new ProcessManagementException(errMsg, axisFault);
}
eprType.setServiceLocations(sLocation);
eprsType.addEndpointRef(eprType);
}
pInfo.setEndpoints(eprsType);
}
// if (processInfo.getInvokeList() != null) {
// for (TInvoke invoke : processInfo.getInvokeList()) {
// String plinkName = invoke.getPartnerLink();
// TService service = invoke.getService();
// /* NOTE:Service can be null for partner links*/
// if (service == null) {
// continue;
// }
// if (log.isDebugEnabled()) {
// log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" +
// plinkName + " -->" + service);
// }
//
// QName serviceName = service.getName();
// }
// }
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-business-process by wso2.
the class RegistrationService method registerOperation.
@Override
public RegisterResponseType registerOperation(URI uri, EndpointReferenceType endpointReferenceType, OMElement[] omElements) {
if (!CoordinationConfiguration.getInstance().isRegistrationServiceEnabled()) {
log.warn("Registration request is discarded. Registration service is disabled in this server");
return null;
}
if (log.isDebugEnabled()) {
log.debug("Registration request received.");
}
URI htIdentifierURI = null;
try {
htIdentifierURI = new URI(HT_COORDINATION_PROTOCOL);
} catch (URI.MalformedURIException e) {
log.error(e);
}
if (!htIdentifierURI.equals(uri)) {
String errorMsg = "Received an invalid Protocol identifier: " + uri.toString();
log.error(errorMsg);
return null;
}
String participantProtocolService = "";
if (endpointReferenceType != null && endpointReferenceType.getAddress() != null) {
participantProtocolService = endpointReferenceType.getAddress().toString();
} else {
String errorMsg = "Received an invalid Participant Protocol Service";
log.error(errorMsg);
}
String messageID = "";
boolean foundB4PMessageID = false;
if (omElements.length > 0) {
for (OMElement omElement : omElements) {
if (B4P_NAMESPACE.equals(omElement.getNamespace().getNamespaceURI()) && B4P_IDENTIFIER.equals(omElement.getLocalName())) {
messageID = omElement.getText();
foundB4PMessageID = true;
break;
}
}
}
if (!foundB4PMessageID) {
String errorMsg = "no B4P messageID received";
log.error(errorMsg);
return null;
}
if (log.isDebugEnabled()) {
log.debug("Adding message ID: " + messageID + "-> " + participantProtocolService);
}
// Persisting data.
try {
persistData(messageID, participantProtocolService);
} catch (Exception e) {
log.error("Error occurred during persisting data", e);
return null;
}
// Sending Dummy Response.
RegisterResponseType responseType = new RegisterResponseType();
EndpointReferenceType epr = new EndpointReferenceType();
AttributedURI attributedURI = new AttributedURI();
URI b4pProtocolHandlerURI;
try {
// Setting Dummy Address here.
b4pProtocolHandlerURI = new URI(getB4PProtocolHandlerURI());
attributedURI.setAnyURI(b4pProtocolHandlerURI);
} catch (URI.MalformedURIException e) {
log.error("Error occurred while generating b4p protocol handler uri", e);
return null;
}
epr.setAddress(attributedURI);
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace b4pOMNamespace = omFactory.createOMNamespace(B4P_NAMESPACE, B4P_PREFIX);
// Dummy Endpoint
responseType.setCoordinatorProtocolService(epr);
OMElement identifierElement = omFactory.createOMElement(B4P_IDENTIFIER, b4pOMNamespace);
identifierElement.addChild(omFactory.createOMText(identifierElement, messageID));
responseType.addExtraElement(identifierElement);
return responseType;
}
Aggregations