Search in sources :

Example 16 with AxisService

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;
}
Also used : AxisFault(org.apache.axis2.AxisFault) PropertyRule(org.apache.axis2.transport.jms.ctype.PropertyRule) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) ContentTypeRuleSet(org.apache.axis2.transport.jms.ctype.ContentTypeRuleSet) BytesMessage(javax.jms.BytesMessage) MessageTypeRule(org.apache.axis2.transport.jms.ctype.MessageTypeRule) TextMessage(javax.jms.TextMessage)

Example 17 with AxisService

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

Example 18 with AxisService

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);
}
Also used : Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) AxisService(org.apache.axis2.description.AxisService) OMElement(org.apache.axiom.om.OMElement) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 19 with AxisService

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

Example 20 with AxisService

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;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) QName(javax.xml.namespace.QName) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) MessageContext(org.apache.axis2.context.MessageContext) HashMap(java.util.HashMap) Map(java.util.Map)

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