Example usage for javax.xml.ws EndpointReference toString

List of usage examples for javax.xml.ws EndpointReference toString

Introduction

In this page you can find the example usage for javax.xml.ws EndpointReference toString.

Prototype

@Override
public String toString() 

Source Link

Document

Displays EPR infoset for debugging convenience.

Usage

From source file:org.apache.axis2.jaxws.spi.Provider.java

@Override
public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
    if (jaxwsEPR == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference2"));
    }/*from www .  j a v a2  s  .co  m*/

    if (sei == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
    }

    org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils
            .createAxis2EndpointReference("");
    String addressingNamespace = null;

    try {
        addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
    } catch (Exception e) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
    }

    org.apache.axis2.jaxws.spi.ServiceDelegate serviceDelegate = null;

    try {
        ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(axis2EPR, addressingNamespace);
        WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(axis2EPR,
                addressingNamespace);
        URL wsdlLocationURL = null;

        if (wsdlLocation.getLocation() != null) {
            wsdlLocationURL = new URL(wsdlLocation.getLocation());
            if (log.isDebugEnabled()) {
                log.debug("getPort: Using EPR wsdlLocationURL = " + wsdlLocationURL);
            }
        } else {
            wsdlLocationURL = new URL(axis2EPR.getAddress() + "?wsdl");
            if (log.isDebugEnabled()) {
                log.debug("getPort: Using default wsdlLocationURL = " + wsdlLocationURL);
            }
        }

        serviceDelegate = new org.apache.axis2.jaxws.spi.ServiceDelegate(wsdlLocationURL, serviceName.getName(),
                Service.class);
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointUpdateError"), e);
    }

    return serviceDelegate.getPort(axis2EPR, addressingNamespace, sei, features);
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public <T> Dispatch<T> createDispatch(EndpointReference jaxwsEPR, Class<T> type, Mode mode,
        WebServiceFeature... features) {
    if (log.isDebugEnabled()) {
        log.debug("Create Dispatch with epr: " + jaxwsEPR);
    }//w w  w.  ja  v a  2s .c  o  m

    verifyServiceDescriptionActive();
    if (jaxwsEPR == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference"));
    }

    if (!isValidDispatchType(type)) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidType"));
    }

    if (!isValidDispatchTypeWithMode(type, mode)) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidTypeWithMode"));
    }

    org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils
            .createAxis2EndpointReference("");
    String addressingNamespace = null;

    try {
        addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
    } catch (Exception e) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
    }

    EndpointDescription endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, null, axis2EPR,
            addressingNamespace, DescriptionFactory.UpdateType.CREATE_DISPATCH, this);
    if (endpointDesc == null) {
        throw ExceptionFactory.makeWebServiceException(
                Messages.getMessage("endpointDescriptionConstructionFailure", jaxwsEPR.toString()));
    }

    XMLDispatch<T> dispatch = new XMLDispatch<T>(this, endpointDesc, axis2EPR, addressingNamespace, features);

    if (mode != null) {
        dispatch.setMode(mode);
    } else {
        dispatch.setMode(Service.Mode.PAYLOAD);
    }

    if (serviceClient == null)
        serviceClient = getServiceClient(endpointDesc.getPortQName());

    if (type == OMElement.class) {
        if (log.isDebugEnabled()) {
            log.debug("This a Dispatch<OMElement>. The custom builder is installed.");
        }
        ProviderOMContextListener.create(serviceClient.getServiceContext());
    }

    dispatch.setServiceClient(serviceClient);
    dispatch.setType(type);
    return dispatch;
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public Dispatch<Object> createDispatch(EndpointReference jaxwsEPR, JAXBContext context, Mode mode,
        WebServiceFeature... features) {
    if (log.isDebugEnabled()) {
        log.debug("Create Dispatch with epr 2: " + jaxwsEPR);
    }//from w ww.j a v  a  2s  .co m
    verifyServiceDescriptionActive();
    if (jaxwsEPR == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference"));
    }

    org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils
            .createAxis2EndpointReference("");
    String addressingNamespace = null;

    try {
        addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
    } catch (Exception e) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
    }

    EndpointDescription endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, null, axis2EPR,
            addressingNamespace, DescriptionFactory.UpdateType.CREATE_DISPATCH, this);
    if (endpointDesc == null) {
        throw ExceptionFactory.makeWebServiceException(
                Messages.getMessage("endpointDescriptionConstructionFailure", jaxwsEPR.toString()));
    }

    JAXBDispatch<Object> dispatch = new JAXBDispatch(this, endpointDesc, axis2EPR, addressingNamespace,
            features);

    if (mode != null) {
        dispatch.setMode(mode);
    } else {
        dispatch.setMode(Service.Mode.PAYLOAD);
    }

    if (serviceClient == null)
        serviceClient = getServiceClient(endpointDesc.getPortQName());

    dispatch.setJAXBContext(context);
    dispatch.setServiceClient(serviceClient);

    return dispatch;
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
    /* TODO Check to see if WSDL Location is provided.
     * if not check WebService annotation's WSDLLocation
     * if both are not provided then throw exception.
     * (JLB): I'm not sure lack of WSDL should cause an exception
     *//*from w w w . j a va2s  .c  om*/

    if (!isValidWSDLLocation()) {
        //TODO: Should I throw Exception if no WSDL
        //throw ExceptionFactory.makeWebServiceException("WSLD Not found");
    }

    if (jaxwsEPR == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference2"));
    }

    if (sei == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
    }

    org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils
            .createAxis2EndpointReference("");
    String addressingNamespace = null;

    try {
        addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
    } catch (Exception e) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
    }

    return getPort(axis2EPR, addressingNamespace, sei, features);
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

public <T> T getPort(org.apache.axis2.addressing.EndpointReference axis2EPR, String addressingNamespace,
        Class<T> sei, WebServiceFeature... features) {
    verifyServiceDescriptionActive();//  w w w  . ja  v a  2s. c  o  m
    DescriptionBuilderComposite sparseComposite = getPortMetadata();
    resetPortMetadata();
    EndpointDescription endpointDesc = null;

    if (sparseComposite != null) {
        endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, sei, axis2EPR, addressingNamespace,
                DescriptionFactory.UpdateType.GET_PORT, sparseComposite, this);

    } else {
        endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, sei, axis2EPR, addressingNamespace,
                DescriptionFactory.UpdateType.GET_PORT, null, this);
    }

    if (endpointDesc == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("serviceDelegateNoPort", axis2EPR.toString()));

    }

    String[] interfacesNames = new String[] { sei.getName(),
            org.apache.axis2.jaxws.spi.BindingProvider.class.getName() };

    // As required by java.lang.reflect.Proxy, ensure that the interfaces
    // for the proxy are loadable by the same class loader. 
    Class[] interfaces = null;
    // First, let's try loading the interfaces with the SEI classLoader
    ClassLoader classLoader = getClassLoader(sei);
    try {
        interfaces = loadClasses(classLoader, interfacesNames);
    } catch (ClassNotFoundException e1) {
        // Let's try with context classLoader now
        classLoader = getContextClassLoader();
        try {
            interfaces = loadClasses(classLoader, interfacesNames);
        } catch (ClassNotFoundException e2) {
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("serviceDelegateProxyError", e2.getMessage()));
        }
    }

    JAXWSProxyHandler proxyHandler = new JAXWSProxyHandler(this, interfaces[0], endpointDesc, axis2EPR,
            addressingNamespace, features);
    Object proxyClass = Proxy.newProxyInstance(classLoader, interfaces, proxyHandler);
    return sei.cast(proxyClass);
}