Search in sources :

Example 16 with ServiceName

use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.

the class SOAPMessageBodyBasedServiceDispatcher method findService.

public AxisService findService(MessageContext messageContext) throws AxisFault {
    String serviceName = null;
    String localPart = messageContext.getEnvelope().getSOAPBodyFirstElementLocalName();
    if (localPart != null) {
        OMNamespace ns = messageContext.getEnvelope().getSOAPBodyFirstElementNS();
        if (ns != null) {
            String filePart = ns.getNamespaceURI();
            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                log.debug(messageContext.getLogIDString() + "Checking for Service using SOAP message body's first child's namespace : " + filePart);
            }
            String[] values = Utils.parseRequestURLForServiceAndOperation(filePart, messageContext.getConfigurationContext().getServiceContextPath());
            if (values[0] != null) {
                serviceName = values[0];
                AxisConfiguration registry = messageContext.getConfigurationContext().getAxisConfiguration();
                return registry.getService(serviceName);
            }
        }
    }
    return null;
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) OMNamespace(org.apache.axiom.om.OMNamespace)

Example 17 with ServiceName

use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.

the class AxisConfiguration method startService.

public void startService(String serviceName) throws AxisFault {
    AxisService service = allServices.get(serviceName);
    if (service == null) {
        throw new AxisFault(Messages.getMessage("servicenamenotvalid", serviceName));
    }
    service.setActive(true);
    notifyObservers(new AxisEvent(AxisEvent.SERVICE_START, service), service);
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService)

Example 18 with ServiceName

use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.

the class AxisConfiguration method stopService.

public void stopService(String serviceName) throws AxisFault {
    AxisService service = allServices.get(serviceName);
    if (service == null) {
        throw new AxisFault(Messages.getMessage("servicenamenotvalid", serviceName));
    }
    service.setActive(false);
    notifyObservers(new AxisEvent(AxisEvent.SERVICE_STOP, service), service);
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService)

Example 19 with ServiceName

use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.

the class AxisConfiguration method addServiceToExistingServiceGroup.

/**
 * This method is used to add a service to an existing active service group in the axis configuration
 *
 * @param axisService service to be added to the existing service group provided
 * @param serviceGroupName name of the service group which should be existing in the axis configuration
 * @throws AxisFault in case of an error in adding the service to the group specified or if the group is not existing
 */
public void addServiceToExistingServiceGroup(AxisService axisService, String serviceGroupName) throws AxisFault {
    AxisServiceGroup serviceGroup = getServiceGroup(serviceGroupName);
    if (serviceGroup == null) {
        String message = "A ServiceGroup with the provided name " + serviceGroupName + " is not existing";
        log.error(message);
        throw new AxisFault(message);
    }
    if (axisService.getSchemaTargetNamespace() == null) {
        axisService.setSchemaTargetNamespace(Java2WSDLConstants.AXIS2_XSD);
    }
    if (axisService.isUseDefaultChains()) {
        Iterator<AxisOperation> operations = axisService.getOperations();
        while (operations.hasNext()) {
            AxisOperation operation = operations.next();
            phasesinfo.setOperationPhases(operation);
        }
    }
    Map<String, AxisEndpoint> endpoints = axisService.getEndpoints();
    if (endpoints == null || endpoints.size() == 0) {
        org.apache.axis2.deployment.util.Utils.addEndpointsToService(axisService, axisService.getAxisConfiguration());
        endpoints = axisService.getEndpoints();
    }
    String serviceName = axisService.getName();
    addToAllServicesMap(axisService);
    if (endpoints != null) {
        Iterator<String> endpointNameIter = endpoints.keySet().iterator();
        while (endpointNameIter.hasNext()) {
            String endpointName = endpointNameIter.next();
            if (log.isDebugEnabled()) {
                log.debug("Adding service to allEndpoints map: (" + serviceName + "," + endpointName + ") ");
            }
            allEndpoints.put(serviceName + "." + endpointName, axisService);
        }
        if (log.isDebugEnabled()) {
            log.debug("After adding to allEndpoints map, size is " + allEndpoints.size());
        }
    }
    serviceGroup.addService(axisService);
    if (!axisService.isClientSide()) {
        notifyObservers(new AxisEvent(AxisEvent.SERVICE_DEPLOY, axisService), axisService);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisOperation(org.apache.axis2.description.AxisOperation) AxisEndpoint(org.apache.axis2.description.AxisEndpoint) AxisServiceGroup(org.apache.axis2.description.AxisServiceGroup)

Example 20 with ServiceName

use of org.apache.axis2.addressing.metadata.ServiceName in project axis-axis2-java-core by apache.

the class AxisConfiguration method addServiceGroup.

public synchronized void addServiceGroup(AxisServiceGroup axisServiceGroup) throws AxisFault {
    axisServiceGroup.setParent(this);
    notifyObservers(new AxisEvent(AxisEvent.SERVICE_DEPLOY, axisServiceGroup), axisServiceGroup);
    AxisService axisService;
    Iterator<AxisService> services = axisServiceGroup.getServices();
    while (services.hasNext()) {
        axisService = services.next();
        if (axisService.getSchemaTargetNamespace() == null) {
            axisService.setSchemaTargetNamespace(Java2WSDLConstants.AXIS2_XSD);
        }
    }
    services = axisServiceGroup.getServices();
    while (services.hasNext()) {
        axisService = services.next();
        if (axisService.isUseDefaultChains()) {
            Iterator<AxisOperation> operations = axisService.getOperations();
            while (operations.hasNext()) {
                AxisOperation operation = operations.next();
                phasesinfo.setOperationPhases(operation);
            }
        }
    }
    Iterator<AxisModule> enModule = getEngagedModules().iterator();
    while (enModule.hasNext()) {
        axisServiceGroup.engageModule(enModule.next());
    }
    services = axisServiceGroup.getServices();
    ArrayList<AxisService> servicesIAdded = new ArrayList<AxisService>();
    while (services.hasNext()) {
        axisService = services.next();
        processEndpoints(axisService, axisService.getAxisConfiguration());
        Map<String, AxisEndpoint> endpoints = axisService.getEndpoints();
        String serviceName = axisService.getName();
        try {
            addToAllServicesMap(axisService);
        } catch (AxisFault axisFault) {
            // remove all the ones we added...
            for (AxisService service : servicesIAdded) {
                allServices.remove(service.getName());
            }
            // And toss this in case anyone wants it?
            throw axisFault;
        }
        servicesIAdded.add(axisService);
        if (endpoints != null) {
            Iterator<String> endpointNameIter = endpoints.keySet().iterator();
            while (endpointNameIter.hasNext()) {
                String endpointName = endpointNameIter.next();
                if (log.isDebugEnabled()) {
                    log.debug("Adding service to allEndpoints map: (" + serviceName + "," + endpointName + ") ");
                }
                allEndpoints.put(serviceName + "." + endpointName, axisService);
            }
            if (log.isDebugEnabled()) {
                log.debug("After adding to allEndpoints map, size is " + allEndpoints.size());
            }
        }
        if (!axisService.isClientSide()) {
            notifyObservers(new AxisEvent(AxisEvent.SERVICE_DEPLOY, axisService), axisService);
        }
    }
    // serviceGroups.put(axisServiceGroup.getServiceGroupName(),
    // axisServiceGroup);
    addChild(axisServiceGroup);
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) ArrayList(java.util.ArrayList) AxisEndpoint(org.apache.axis2.description.AxisEndpoint) AxisModule(org.apache.axis2.description.AxisModule)

Aggregations

AxisService (org.apache.axis2.description.AxisService)116 AxisFault (org.apache.axis2.AxisFault)54 AxisOperation (org.apache.axis2.description.AxisOperation)36 QName (javax.xml.namespace.QName)27 ArrayList (java.util.ArrayList)26 OMElement (org.apache.axiom.om.OMElement)26 IOException (java.io.IOException)21 URL (java.net.URL)19 ServiceClient (org.apache.axis2.client.ServiceClient)19 Options (org.apache.axis2.client.Options)18 HashMap (java.util.HashMap)17 Service (javax.xml.ws.Service)17 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)17 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)17 File (java.io.File)16 Iterator (java.util.Iterator)16 EndpointReference (org.apache.axis2.addressing.EndpointReference)16 List (java.util.List)15 Map (java.util.Map)15 MessageContext (org.apache.axis2.context.MessageContext)15