Java Code Examples for org.apache.axis2.engine.AxisConfiguration#getTransportIn()

The following examples show how to use org.apache.axis2.engine.AxisConfiguration#getTransportIn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static String getWsdlInformation(String serviceName,
                                          AxisConfiguration axisConfig) throws AxisFault {
    String ip;
    try {
        ip = NetworkUtils.getLocalHostname();
    } catch (SocketException e) {
        throw new AxisFault("Cannot get local host name", e);
    }

    TransportInDescription transportInDescription = axisConfig.getTransportIn("http");

    if (transportInDescription == null) {
        transportInDescription = axisConfig.getTransportIn("https");
    }

    if (transportInDescription != null) {
        EndpointReference[] epr =
                transportInDescription.getReceiver().getEPRsForService(serviceName, ip);
        String wsdlUrlPrefix = epr[0].getAddress();
        if (wsdlUrlPrefix.endsWith("/")) {
            wsdlUrlPrefix = wsdlUrlPrefix.substring(0, wsdlUrlPrefix.length() - 1);
        }
        return wsdlUrlPrefix + "?wsdl";
    }
    return null;
}
 
Example 2
Source File: WSDL2Code.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private String getWsdlInformation(String serviceName, AxisConfiguration axisConfig)
        throws AxisFault {
    String ip;
    try {
        ip = NetworkUtils.getLocalHostname();
    } catch (SocketException e) {
        throw new AxisFault("Cannot get local host name", e);
    }
    TransportInDescription http = axisConfig.getTransportIn("http");
    if (http != null) {
        EndpointReference epr =
                ((HttpTransportListener) http.getReceiver()).
                getEPRForService(serviceName, ip);
        String wsdlUrlPrefix = epr.getAddress();
        if (wsdlUrlPrefix.endsWith("/")) {
            wsdlUrlPrefix = wsdlUrlPrefix.substring(0, wsdlUrlPrefix.length() - 1);
        }
        return wsdlUrlPrefix + "?wsdl";
    }
    return null;
}
 
Example 3
Source File: Utils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static String[] getWsdlInformation(String serviceName,
                                          AxisConfiguration axisConfig) throws AxisFault {
    String ip;
    try {
        ip = NetworkUtils.getLocalHostname();
    } catch (SocketException e) {
        throw new AxisFault("Cannot get local host name", e);
    }

    //TODO Ideally, The transport on which wsdls are displayed, should be configurable.
    TransportInDescription transportInDescription = axisConfig.getTransportIn("http");

    if (transportInDescription == null) {
        transportInDescription = axisConfig.getTransportIn("https");
    }

    if (transportInDescription != null) {
        EndpointReference[] epr =
                transportInDescription.getReceiver().getEPRsForService(serviceName, ip);
        String wsdlUrlPrefix = epr[0].getAddress();
        if (wsdlUrlPrefix.endsWith("/")) {
            wsdlUrlPrefix = wsdlUrlPrefix.substring(0, wsdlUrlPrefix.length() - 1);
        }
        return new String[]{wsdlUrlPrefix + "?wsdl", wsdlUrlPrefix + "?wsdl2"};
    }
    return new String[]{};
}
 
Example 4
Source File: AbstractTransportService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public TransportParameter[] getGlobalTransportParameters(
            boolean listener, AxisConfiguration axisConfig) throws Exception {

        ParameterInclude transport;
//        TransportPersistenceManager transportPM = new TransportPersistenceManager(axisConfig);
        if (listener) {
            transport = axisConfig.getTransportIn(transportName);
        } else {
            transport = axisConfig.getTransportOut(transportName);
        }

        return getParameters(transport);
    }
 
Example 5
Source File: AbstractTransportService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public boolean isEnabled(boolean listener, AxisConfiguration axisConfig) {
    if (listener) {
        return axisConfig.getTransportIn(transportName) != null;
    } else {
        return axisConfig.getTransportOut(transportName) != null;
    }
}
 
Example 6
Source File: AbstractTransportService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void addTransportParameter(TransportParameter param,
                                  boolean listener, ConfigurationContext cfgCtx) throws Exception {
    ParameterInclude transport;
    AxisConfiguration axisConfig = cfgCtx.getAxisConfiguration();
    if (listener) {
        transport = axisConfig.getTransportIn(transportName);
    } else {
        transport = axisConfig.getTransportOut(transportName);
    }

    if (transport == null) {

    } else {
        TransportParameter[] newParams;
        TransportParameter[] params = getGlobalTransportParameters(listener, axisConfig);

        if (params == null) {
            newParams = new TransportParameter[]{param};
        } else {
            boolean overwritten = false;
            for (int i = 0; i < params.length; i++) {
                if (params[i].getName().equals(param.getName())) {
                    params[i] = param;
                    overwritten = true;
                    break;
                }
            }

            if (overwritten) {
                newParams = params;
            } else {
                newParams = new TransportParameter[params.length + 1];
                System.arraycopy(params, 0, newParams, 0, params.length);
                newParams[newParams.length - 1] = param;
            }
        }

        updateGlobalTransportParameters(newParams, listener, cfgCtx);
    }
}
 
Example 7
Source File: AbstractTransportService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void removeTransportParameter(String param,
                                     boolean listener, ConfigurationContext cfgCtx) throws Exception {
    ParameterInclude transport;
    AxisConfiguration axisConfig = cfgCtx.getAxisConfiguration();
    if (listener) {
        transport = axisConfig.getTransportIn(transportName);
    } else {
        transport = axisConfig.getTransportOut(transportName);
    }

    if (transport == null) {
    } else {
        TransportParameter[] params = getGlobalTransportParameters(listener, axisConfig);
        if (params != null) {
            List<TransportParameter> newParams = new ArrayList<TransportParameter>();
            boolean paramFound = false;
            for (TransportParameter p : params) {
                if (p.getName().equals(param)) {
                    paramFound = true;
                    continue;
                }
                newParams.add(p);
            }

            if (paramFound) {
                updateGlobalTransportParameters(newParams.toArray(
                        new TransportParameter[newParams.size()]), listener, cfgCtx);
                return;
            }
        }

        throw new CarbonException("The transport parameter : " + param + " does not exist");
    }
}