Search in sources :

Example 21 with AxisService

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) };
}
Also used : AxisFault(org.apache.axis2.AxisFault) SocketException(java.net.SocketException) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 22 with AxisService

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) {
        }
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) OMNamespace(org.apache.axiom.om.OMNamespace) AxisCallback(org.apache.axis2.client.async.AxisCallback) AxisService(org.apache.axis2.description.AxisService) OMElement(org.apache.axiom.om.OMElement) XMLStreamException(javax.xml.stream.XMLStreamException) OMFactory(org.apache.axiom.om.OMFactory) XMLStreamException(javax.xml.stream.XMLStreamException) ServiceClient(org.apache.axis2.client.ServiceClient) MessageContext(org.apache.axis2.context.MessageContext)

Example 23 with AxisService

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;
}
Also used : AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter)

Example 24 with AxisService

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;
}
Also used : AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 25 with AxisService

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);
}
Also used : InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) AxisService(org.apache.axis2.description.AxisService) RawXMLINOutMessageReceiver(org.apache.axis2.receivers.RawXMLINOutMessageReceiver) Parameter(org.apache.axis2.description.Parameter) RawXMLINOnlyMessageReceiver(org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver) InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation)

Aggregations

AxisService (org.apache.axis2.description.AxisService)19 AxisFault (org.apache.axis2.AxisFault)11 AxisOperation (org.apache.axis2.description.AxisOperation)7 Parameter (org.apache.axis2.description.Parameter)6 EndpointReference (org.apache.axis2.addressing.EndpointReference)5 QName (javax.xml.namespace.QName)4 Map (java.util.Map)3 OMElement (org.apache.axiom.om.OMElement)3 MessageContext (org.apache.axis2.context.MessageContext)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 SocketException (java.net.SocketException)2 HashMap (java.util.HashMap)2 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)2 Options (org.apache.axis2.client.Options)2 ServiceClient (org.apache.axis2.client.ServiceClient)2 MultipleEntryHashMap (org.apache.axis2.util.MultipleEntryHashMap)2 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1