use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class TCPEndpoint method getEndpointReferences.
public EndpointReference[] getEndpointReferences(AxisService service, String ip) throws AxisFault {
if (host == null && ip == null) {
try {
ip = Utils.getIpAddress(getListener().getConfigurationContext().getAxisConfiguration());
} catch (SocketException ex) {
throw new AxisFault("Unable to determine the host's IP address", ex);
}
}
String url = "tcp://" + (host != null ? host : ip) + ":" + port;
String context = getListener().getConfigurationContext().getServiceContextPath();
url += (context.startsWith("/") ? "" : "/") + context + (context.endsWith("/") ? "" : "/") + (getService() == null ? service.getName() : getServiceName());
if (!contentType.equals(TCPConstants.TCP_DEFAULT_CONTENT_TYPE)) {
url += "?contentType=" + contentType;
}
return new EndpointReference[] { new EndpointReference(url) };
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class TCPTwoChannelEchoRawXMLTest method testEchoXMLCompleteASync.
public void testEchoXMLCompleteASync() throws Exception {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement method = fac.createOMElement("echoOMElement", omNs);
OMElement value = fac.createOMElement("myValue", omNs);
value.setText("Isaac Asimov, The Foundation Trilogy");
method.addChild(value);
ServiceClient sender;
try {
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_TCP);
options.setUseSeparateListener(true);
options.setAction(operationName.getLocalPart());
AxisCallback axisCallback = new AxisCallback() {
public void onMessage(MessageContext msgContext) {
try {
msgContext.getEnvelope().serialize(StAXUtils.createXMLStreamWriter(System.out));
finish = true;
} catch (XMLStreamException e) {
onError(e);
}
}
public void onFault(MessageContext msgContext) {
try {
msgContext.getEnvelope().serialize(StAXUtils.createXMLStreamWriter(System.out));
finish = true;
} catch (XMLStreamException e) {
onError(e);
}
}
public void onError(Exception e) {
log.info(e.getMessage());
finish = true;
}
public void onComplete() {
finish = true;
}
};
AxisService serviceClient = Utils.createSimpleServiceforClient(serviceName, Echo.class.getName(), operationName);
sender = new ServiceClient(configContext, serviceClient);
sender.setOptions(options);
sender.sendReceiveNonBlocking(operationName, method, axisCallback);
int index = 0;
while (!finish) {
Thread.sleep(1000);
index++;
if (index > 10) {
throw new AxisFault("Server was shutdown as the async response take too long to complete");
}
}
} finally {
if (finish) {
}
}
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class MqttEndpoint method loadConfiguration.
@Override
public boolean loadConfiguration(ParameterInclude parameterInclude) throws AxisFault {
if (!(parameterInclude instanceof AxisService)) {
return false;
}
AxisService service = (AxisService) parameterInclude;
mqttConnectionFactory = mqttListener.getConnectionFactory(service);
if (mqttConnectionFactory == null) {
return false;
}
Parameter topicName = service.getParameter(MqttConstants.MQTT_TOPIC_NAME);
Parameter qosLevel = service.getParameter(MqttConstants.MQTT_QOS);
Parameter contentTypeValue = service.getParameter(MqttConstants.CONTENT_TYPE);
Parameter cleanSession = service.getParameter(MqttConstants.MQTT_SESSION_CLEAN);
Parameter clientId = service.getParameter(MqttConstants.MQTT_CLIENT_ID);
Parameter hostName = service.getParameter(MqttConstants.MQTT_SERVER_HOST_NAME);
Parameter port = service.getParameter(MqttConstants.MQTT_SERVER_PORT);
Parameter sslEnable = service.getParameter(MqttConstants.MQTT_SSL_ENABLE);
Parameter tempStore = service.getParameter(MqttConstants.MQTT_TEMP_STORE);
if (topicName != null) {
setTopic(((String) topicName.getValue()));
} else {
setTopic(mqttConnectionFactory.getTopic());
}
if (qosLevel != null) {
setQOS(Integer.parseInt((String) qosLevel.getValue()));
} else {
setQOS(mqttConnectionFactory.getQOS());
}
if (contentTypeValue != null) {
setContentType(((String) contentTypeValue.getValue()));
} else {
setContentType(mqttConnectionFactory.getContentType());
}
if (cleanSession != null) {
setCleanSession(Boolean.parseBoolean((String) cleanSession.getValue()));
} else {
setCleanSession(mqttConnectionFactory.getCleanSession());
}
if (clientId != null) {
setClientId((String) clientId.getValue());
} else {
setClientId(mqttConnectionFactory.getClientId());
}
if (hostName != null) {
setHostName((String) hostName.getValue());
} else {
setHostName(mqttConnectionFactory.getHostName());
}
if (port != null) {
setPort((String) port.getValue());
} else {
setPort(mqttConnectionFactory.getPort());
}
if (sslEnable != null) {
setSSLEnabled((String) sslEnable.getValue());
} else {
setSSLEnabled(mqttConnectionFactory.getSSLEnable());
}
if (tempStore != null) {
setTempStore((String) tempStore.getValue());
} else {
setTempStore(mqttConnectionFactory.getTempStore());
}
return true;
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class MSMQEndpoint method loadConfiguration.
@Override
public boolean loadConfiguration(ParameterInclude params) {
// only support endpoints configured at service level
if (!(params instanceof AxisService)) {
return false;
}
AxisService service = (AxisService) params;
// we just assume that the service name==queue name
Parameter destParam = service.getParameter(MSMQConstants.PARAM_DESTINATION);
if (destParam != null) {
msmqDestinationQueueName = (String) destParam.getValue();
} else {
msmqDestinationQueueName = service.getName();
}
endpointReferences.add(new EndpointReference(MSMQConnectionManager.getReceiverQueueFullName(getServiceName())));
// TODO: improve MSMQ transport for two way messaging..
Parameter contentTypeParam = service.getParameter(MSMQConstants.PARAM_CONTENT_TYPE);
serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(service, workerPool);
serviceTaskManager.setMsmqMessageReceiver(new MSMQMessageReceiver(listener, msmqDestinationQueueName, this));
// Deal with content type
if (contentTypeParam.getValue() != null && !"".equals(String.valueOf(contentTypeParam.getValue()).trim())) {
serviceTaskManager.setContentType(String.valueOf(contentTypeParam.getValue()));
}
return true;
}
use of org.apache.axis2.description.AxisService in project wso2-axis2-transports by wso2.
the class UtilsTransportServer method deployEchoService.
/**
* Deploy the standard Echo service with the custom parameters passed in
* @param name the service name to assign
* @param parameters the parameters for the service
* @throws Exception
*/
public void deployEchoService(String name, List<Parameter> parameters) throws Exception {
AxisService service = new AxisService(name);
service.setClassLoader(Thread.currentThread().getContextClassLoader());
service.addParameter(new Parameter(Constants.SERVICE_CLASS, Echo.class.getName()));
// add operation echoOMElement
AxisOperation axisOp = new InOutAxisOperation(new QName("echoOMElement"));
axisOp.setMessageReceiver(new RawXMLINOutMessageReceiver());
axisOp.setStyle(WSDLConstants.STYLE_RPC);
service.addOperation(axisOp);
service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement", axisOp);
// add operation echoOMElementNoResponse
axisOp = new InOutAxisOperation(new QName("echoOMElementNoResponse"));
axisOp.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
axisOp.setStyle(WSDLConstants.STYLE_RPC);
service.addOperation(axisOp);
service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/echoOMElementNoResponse", axisOp);
for (Parameter parameter : parameters) {
service.addParameter(parameter);
}
cfgCtx.getAxisConfiguration().addService(service);
}
Aggregations