use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class JMSEndpoint method loadConfiguration.
@Override
public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
// We only support endpoints configured at service level
if (!(params instanceof AxisService)) {
return false;
}
AxisService service = (AxisService) params;
cf = listener.getConnectionFactory(service);
if (cf == null) {
return false;
}
Parameter destParam = service.getParameter(JMSConstants.PARAM_DESTINATION);
if (destParam != null) {
jndiDestinationName = (String) destParam.getValue();
} else {
// Assume that the JNDI destination name is the same as the service name
jndiDestinationName = service.getName();
}
Parameter destTypeParam = service.getParameter(JMSConstants.PARAM_DEST_TYPE);
if (destTypeParam != null) {
String paramValue = (String) destTypeParam.getValue();
if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) || JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue)) {
setDestinationType(paramValue);
} else {
throw new AxisFault("Invalid destinaton type value " + paramValue);
}
} else {
log.debug("JMS destination type not given. default queue");
destinationType = JMSConstants.QUEUE;
}
Parameter replyDestTypeParam = service.getParameter(JMSConstants.PARAM_REPLY_DEST_TYPE);
if (replyDestTypeParam != null) {
String paramValue = (String) replyDestTypeParam.getValue();
if (JMSConstants.DESTINATION_TYPE_QUEUE.equals(paramValue) || JMSConstants.DESTINATION_TYPE_TOPIC.equals(paramValue)) {
setReplyDestinationType(paramValue);
} else {
throw new AxisFault("Invalid destination type value " + paramValue);
}
} else {
log.debug("JMS reply destination type not given. default queue");
replyDestinationType = JMSConstants.DESTINATION_TYPE_QUEUE;
}
jndiReplyDestinationName = ParamUtils.getOptionalParam(service, JMSConstants.PARAM_REPLY_DESTINATION);
Parameter contentTypeParam = service.getParameter(JMSConstants.CONTENT_TYPE_PARAM);
if (contentTypeParam == null) {
contentTypeRuleSet = new ContentTypeRuleSet();
contentTypeRuleSet.addRule(new PropertyRule(BaseConstants.CONTENT_TYPE));
contentTypeRuleSet.addRule(new MessageTypeRule(BytesMessage.class, "application/octet-stream"));
contentTypeRuleSet.addRule(new MessageTypeRule(TextMessage.class, "text/plain"));
} else {
contentTypeRuleSet = ContentTypeRuleFactory.parse(contentTypeParam);
}
// compute service EPR and keep for later use
computeEPRs();
serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(cf, service, workerPool);
serviceTaskManager.setJmsMessageReceiver(new JMSMessageReceiver(listener, cf, this));
// Fix for ESBJAVA-3687, retrieve JMS transport property transport.jms.MessagePropertyHyphens and set this
// into the msgCtx
Parameter paramHyphenSupport = service.getParameter(JMSConstants.PARAM_JMS_HYPHEN_MODE);
if (paramHyphenSupport != null) {
if (((String) paramHyphenSupport.getValue()).equals(JMSConstants.HYPHEN_MODE_REPLACE)) {
hyphenSupport = JMSConstants.HYPHEN_MODE_REPLACE;
} else if (((String) paramHyphenSupport.getValue()).equals(JMSConstants.HYPHEN_MODE_DELETE)) {
hyphenSupport = JMSConstants.HYPHEN_MODE_DELETE;
}
}
return true;
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class Endpoint method getEndpointReferences.
@Override
public EndpointReference[] getEndpointReferences(AxisService service, String ip) throws AxisFault {
if (ip == null) {
try {
ip = Utils.getIpAddress(getListener().getConfigurationContext().getAxisConfiguration());
} catch (SocketException ex) {
throw new AxisFault("Unable to determine the host's IP address", ex);
}
}
StringBuilder epr = new StringBuilder("udp://");
epr.append(ip);
epr.append(':');
epr.append(getPort());
// need to include the service path in the EPR.
if (getService() == null) {
epr.append('/');
epr.append(getConfigurationContext().getServiceContextPath());
epr.append('/');
epr.append(service.getName());
}
epr.append("?contentType=");
epr.append(getContentType());
return new EndpointReference[] { new EndpointReference(epr.toString()) };
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class UDPTest method testSoapOverUdpWithEchoService.
public void testSoapOverUdpWithEchoService() throws Exception {
Options options = new Options();
options.setTo(new EndpointReference("udp://127.0.0.1:3333?contentType=text/xml+soap"));
options.setAction(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement");
options.setUseSeparateListener(true);
options.setTimeOutInMilliSeconds(Long.MAX_VALUE);
ServiceClient serviceClient = new ServiceClient(getClientCfgCtx(), null);
serviceClient.setOptions(options);
// We need to set up the anonymous service Axis uses to get the response
AxisService clientService = serviceClient.getServiceContext().getAxisService();
clientService.addParameter(UDPConstants.PORT_KEY, 4444);
clientService.addParameter(UDPConstants.CONTENT_TYPE_KEY, "text/xml+soap");
OMElement response = serviceClient.sendReceive(createPayload());
assertEchoResponse(response);
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class AbstractTransportListenerEx method startListeningForService.
@Override
protected final void startListeningForService(AxisService service) throws AxisFault {
E endpoint = createEndpoint();
endpoint.init(this, service);
if (endpoint.loadConfiguration(service)) {
startEndpoint(endpoint);
serviceEndpoints.add(endpoint);
} else if (globalEndpoint != null) {
return;
} else {
throw new AxisFault("Service doesn't have configuration information for transport " + getTransportName());
}
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class DefaultSMSMessageBuilderImpl method buildMessaage.
public MessageContext buildMessaage(SMSMessage msg, ConfigurationContext configurationContext) throws InvalidMessageFormatException {
String message = msg.getContent();
String sender = msg.getSender();
String receiver = msg.getReceiver();
String[] parts = message.split(":");
// may be can add feature to send message format for a request like ????
if (parts.length < 2) {
throw new InvalidMessageFormatException("format must be \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\"");
} else {
AxisConfiguration repo = configurationContext.getAxisConfiguration();
MessageContext messageContext = configurationContext.createMessageContext();
parts = trimSplited(parts);
try {
AxisService axisService = repo.getService(parts[0]);
if (axisService == null) {
throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist");
} else {
messageContext.setAxisService(axisService);
AxisOperation axisOperation = axisService.getOperation(new QName(parts[1]));
if (axisOperation == null) {
throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist");
}
messageContext.setAxisOperation(axisOperation);
messageContext.setAxisMessage(axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
Map params = getParams(parts, 2);
SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext, params);
messageContext.setServerSide(true);
messageContext.setEnvelope(soapEnvelope);
TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms");
TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms");
messageContext.setIncomingTransportName("sms");
messageContext.setProperty(SMSTransportConstents.SEND_TO, sender);
messageContext.setProperty(SMSTransportConstents.DESTINATION, receiver);
messageContext.setTransportIn(in);
messageContext.setTransportOut(out);
handleSMSProperties(msg, messageContext);
return messageContext;
}
} catch (AxisFault axisFault) {
log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" + axisFault);
}
}
return null;
}
Aggregations