Example usage for javax.xml.namespace QName valueOf

List of usage examples for javax.xml.namespace QName valueOf

Introduction

In this page you can find the example usage for javax.xml.namespace QName valueOf.

Prototype

public static QName valueOf(String qNameAsString) 

Source Link

Document

<p><code>QName</code> derived from parsing the formatted <code>String</code>.</p> <p>If the <code>String</code> is <code>null</code> or does not conform to #toString() QName.toString() formatting, an <code>IllegalArgumentException</code> is thrown.</p> <p><em>The <code>String</code> <strong>MUST</strong> be in the form returned by #toString() QName.toString() .</em></p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.ow2.petals.binding.restproxy.in.AbstractRESTService.java

/**
 * @throws RESTException//from   www .jav  a 2s .c  o  m
 * 
 */
public void process(String path, String endpointName, QName serviceName, QName interfaceName,
        HttpServletRequest request, HttpServletResponse response) throws RESTException {
    Message out = null;
    Message message = new MessageImpl();

    String contentType = HTTPUtils.getContentType(request.getContentType());

    if (contentType == null) {
        contentType = org.ow2.petals.messaging.framework.Constants.MimeTypes.TYPE_RAW;
        this.logger.debug("Content type is null, setting default : " + contentType);
    } else {
        this.logger.debug("Initial content type is : " + contentType);
    }

    String encoding = this.getEncoding(request);
    this.logger.debug("Char encoding is : " + encoding);

    ReaderRegistry readers = EngineFactory.getEngine().getComponent(ReaderRegistry.class);
    if ((readers != null) && (readers.get(contentType) != null)) {
        try {
            message = readers.get(contentType).read(request.getInputStream(), encoding);
        } catch (ReaderException e) {
            throw new RESTException(e);
        } catch (IOException e) {
            throw new RESTException(e);
        }

        // add some additional properties which are common to all
        message.putAll(this.createProperties(path, request));

        try {
            message.put(org.ow2.petals.messaging.framework.message.Constants.OPERATION,
                    QName.valueOf(request.getMethod().toUpperCase()));
            message.put(org.ow2.petals.messaging.framework.message.Constants.SERVICE, serviceName);
            message.put(org.ow2.petals.messaging.framework.message.Constants.INTERFACE, interfaceName);
            // FIXME = This should be in the context and not iin the code
            message.put(org.ow2.petals.messaging.framework.message.Constants.PROTOCOL, "jbi");
            MessagingEngine messagingEngine = EngineFactory.getEngine().getComponent(MessagingEngine.class);
            if (messagingEngine != null) {
                out = messagingEngine.send(message);
            } else {
                // TODO = error
                out = null;
            }
        } catch (MessagingException e) {
            throw new RESTException(e);
        }

        if (out != null) {
            this.writeResponse(out, response);
        } else {
            throw new RESTException("No message response...");
        }
    } else {
        throw new RESTException("Can not find a valid reader for type '" + contentType + "'");
    }
}

From source file:org.petalslink.dsb.kernel.registry.BaseEndpointRegistry.java

protected void registerEndpoint(org.ow2.petals.jbi.messaging.endpoint.ServiceEndpoint serviceEndpoint)
        throws org.ow2.petals.jbi.messaging.registry.RegistryException {

    if (serviceEndpoint == null) {
        throw new org.ow2.petals.jbi.messaging.registry.RegistryException(
                "Can not register a null service endpoint");
    }//from  ww  w .jav a 2  s .c om

    // TODO: check if the service is already registered

    org.ow2.petals.registry.api.Endpoint endpoint = new org.ow2.petals.registry.api.Endpoint();
    if (serviceEndpoint.getDescription() != null) {
        try {
            // let's say that the description is an XML one!
            endpoint.setDescription(XMLHelper.createStringFromDOMDocument(serviceEndpoint.getDescription()));
        } catch (Exception e) {
            this.log.warning(e.getMessage());
        }
    }
    if (serviceEndpoint.getEndpointName() != null) {
        endpoint.setName(QName.valueOf(serviceEndpoint.getEndpointName()));
    }
    if (serviceEndpoint.getInterfaces() != null) {
        endpoint.setInterface(serviceEndpoint.getInterfaces()[0]);
    }
    endpoint.setService(serviceEndpoint.getServiceName());

    if (serviceEndpoint.getLocation() != null) {
        endpoint.setComponent(serviceEndpoint.getLocation().getComponentName());
        endpoint.setContainer(serviceEndpoint.getLocation().getContainerName());
        endpoint.setSubdomain(serviceEndpoint.getLocation().getSubdomainName());
    }
    endpoint.setType(serviceEndpoint.getType().toString().toLowerCase());

    try {
        // propagate to all
        this.client.put(this.getKey(serviceEndpoint), endpoint, true);
    } catch (RegistryException e) {
        throw new org.ow2.petals.jbi.messaging.registry.RegistryException(e.getMessage());
    }
}

From source file:org.petalslink.dsb.kernel.registry.BaseEndpointRegistry.java

/**
 * {@inheritDoc}/*from   w w  w  .j  a  v a 2 s. com*/
 */
public ServiceEndpoint getEndpoint(QName service, String name)
        throws org.ow2.petals.jbi.messaging.registry.RegistryException {

    if (this.log.isDebugEnabled()) {
        this.log.debug("Entering method : getEndpoint with params service, name = " + service + ", " + name);
    }

    org.ow2.petals.jbi.messaging.endpoint.ServiceEndpoint result = null;

    Query q = new Query();
    q.setEndpoint(QName.valueOf(name));
    q.setService(service);

    try {
        List<Endpoint> ep = this.client.lookup(q, false);
        // FIXME : get the first one...
        if ((ep != null) && (ep.size() > 0)) {
            Endpoint e = ep.get(0);
            if ((e.getType() != null)
                    && e.getType().equalsIgnoreCase(EndpointType.EXTERNAL.toString().toLowerCase())) {

                JBIServiceEndpointImpl xe = new JBIServiceEndpointImpl();
                xe.setType(EndpointType.EXTERNAL);
                xe.setStringDescription(e.getDescription());
                xe.setEndpointName(e.getName().toString());
                List<QName> interfaces = new ArrayList<QName>(1);
                interfaces.add(e.getInterface());
                xe.setInterfacesName(interfaces);
                xe.setServiceName(e.getService());
                xe.getLocation().setComponentName(e.getComponent());
                xe.getLocation().setContainerName(e.getContainer());
                xe.getLocation().setSubdomainName(e.getSubdomain());

                result = xe;
            } else if ((e.getType() != null)
                    && e.getType().equalsIgnoreCase(EndpointType.INTERNAL.toString().toLowerCase())) {
                JBIServiceEndpointImpl ie = new JBIServiceEndpointImpl();
                ie.setType(EndpointType.INTERNAL);
                ie.setStringDescription(e.getDescription());
                ie.setEndpointName(e.getName().toString());
                List<QName> interfaces = new ArrayList<QName>(1);
                interfaces.add(e.getInterface());
                ie.setInterfacesName(interfaces);
                ie.setServiceName(e.getService());
                ie.getLocation().setComponentName(e.getComponent());
                ie.getLocation().setContainerName(e.getContainer());
                ie.getLocation().setSubdomainName(e.getSubdomain());
                result = ie;
            } else {
                this.log.warning("UNKNOW EP TYPE " + e.getType());
            }
        }
    } catch (RegistryException e) {
        throw new org.ow2.petals.jbi.messaging.registry.RegistryException(e.getMessage());
    }
    return result;
}

From source file:org.petalslink.dsb.kernel.registry.BaseEndpointRegistry.java

/**
 * {@inheritDoc}/*from w w  w. j a v a  2s . com*/
 */
public String getDescription(String serviceName, String endpointName)
        throws org.ow2.petals.jbi.messaging.registry.RegistryException {

    if (this.log.isDebugEnabled()) {
        this.log.debug("Entering method : getDescription with params serviceName, endpointName = " + serviceName
                + ", " + endpointName);
    }
    final String s = serviceName;
    final String e = endpointName;

    ServiceEndpoint endpoint = new ServiceEndpoint() {

        public QName getServiceName() {
            return QName.valueOf(s);
        }

        public QName[] getInterfaces() {
            return null;
        }

        public String getEndpointName() {
            return e;
        }

        public DocumentFragment getAsReference(QName operationName) {
            return null;
        }

        public EndpointType getType() {
            return null;
        }

        public Document getDescription() {
            return null;
        }

        public List<QName> getInterfacesName() {
            return null;
        }

        public Location getLocation() {
            return null;
        }

        public void setType(EndpointType type) {
        }

        public Map<String, String> getProperties() {
            return null;
        }
    };
    // TODO : CHA2012 : check new implementation
    Document doc = this.getEndpointDescriptorForEndpoint(endpoint);
    if (doc != null) {
        try {
            return XMLHelper.createStringFromDOMDocument(doc);
        } catch (TransformerException e1) {
            throw new org.ow2.petals.jbi.messaging.registry.RegistryException(e1);
        }
    }
    return null;
}

From source file:org.petalslink.dsb.kernel.registry.BaseEndpointRegistry.java

/**
 * {@inheritDoc}/*from   w w w.j a v  a  2  s  . com*/
 */
public List<ServiceEndpoint> query(String endpointName, QName itf, QName service, String containerName,
        String componentName, String subDomainName, String type)
        throws org.ow2.petals.jbi.messaging.registry.RegistryException {
    if (this.log.isDebugEnabled()) {
        this.log.debug("Entering method : query");
    }
    List<ServiceEndpoint> result = new ArrayList<ServiceEndpoint>();

    Query q = new Query();
    if (endpointName != null) {
        q.setEndpoint(QName.valueOf(endpointName));
    }

    q.setInterface(itf);
    q.setService(service);
    q.setContainer(containerName);
    q.setComponent(componentName);
    q.setSubDomain(subDomainName);
    q.setType(type);

    try {
        List<Endpoint> list = this.client.lookup(q, true);
        for (Endpoint endpoint : list) {
            if (this.log.isDebugEnabled()) {
                this.log.debug("Found endoint : " + endpoint);
            }
            JBIServiceEndpointImpl ep = new JBIServiceEndpointImpl();
            ep.setType(EndpointType.INTERNAL);
            ep.setStringDescription(endpoint.getDescription());
            ep.setEndpointName(endpoint.getName().toString());
            List<QName> itfs = new ArrayList<QName>(1);
            itfs.add(endpoint.getInterface());
            ep.setInterfacesName(itfs);
            ep.setServiceName(endpoint.getService());
            ep.getLocation().setComponentName(endpoint.getComponent());
            ep.getLocation().setContainerName(endpoint.getContainer());
            ep.getLocation().setSubdomainName(endpoint.getSubdomain());
            result.add(ep);
        }
    } catch (RegistryException e) {
        throw new org.ow2.petals.jbi.messaging.registry.RegistryException(e.getMessage());
    }
    return result;
}

From source file:org.reficio.ws.builder.core.Wsdl.java

public SoapBuilder getBuilder(String bindingName, SoapContext context) {
    Preconditions.checkNotNull(bindingName, "BindingName cannot be null");
    return getBuilder(QName.valueOf(bindingName), context);
}

From source file:org.sakaiproject.nakamura.auth.cas.CasAuthenticationHandler.java

private String retrieveCredentials(String responseBody) {
    String username = null;/*  w ww.  j  a  v  a 2  s  .co m*/
    String pgtIou = null;
    String failureCode = null;
    String failureMessage = null;

    try {
        XMLInputFactory xmlInputFactory = new WstxInputFactory();
        xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, true);
        xmlInputFactory.setProperty(XMLInputFactory.IS_VALIDATING, false);
        xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
        XMLEventReader eventReader = xmlInputFactory.createXMLEventReader(new StringReader(responseBody));

        while (eventReader.hasNext()) {
            XMLEvent event = eventReader.nextEvent();

            // process the event if we're starting an element
            if (event.isStartElement()) {
                StartElement startEl = event.asStartElement();
                QName startElName = startEl.getName();
                String startElLocalName = startElName.getLocalPart();
                LOGGER.debug(responseBody);

                /*
                 * Example of failure XML
                <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
                  <cas:authenticationFailure code='INVALID_REQUEST'>
                    &#039;service&#039; and &#039;ticket&#039; parameters are both required
                  </cas:authenticationFailure>
                </cas:serviceResponse>
                */
                if ("authenticationFailure".equalsIgnoreCase(startElLocalName)) {
                    // get code of the failure
                    Attribute code = startEl.getAttributeByName(QName.valueOf("code"));
                    failureCode = code.getValue();

                    // get the message of the failure
                    event = eventReader.nextEvent();
                    assert event.isCharacters();
                    Characters chars = event.asCharacters();
                    failureMessage = chars.getData();
                    break;
                }

                /*
                 * Example of success XML
                <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
                  <cas:authenticationSuccess>
                    <cas:user>NetID</cas:user>
                  </cas:authenticationSuccess>
                </cas:serviceResponse>
                */
                if ("authenticationSuccess".equalsIgnoreCase(startElLocalName)) {
                    // skip to the user tag start
                    while (eventReader.hasNext()) {
                        event = eventReader.nextTag();
                        if (event.isEndElement()) {
                            if (eventReader.hasNext()) {
                                event = eventReader.nextTag();
                            } else {
                                break;
                            }
                        }
                        assert event.isStartElement();
                        startEl = event.asStartElement();
                        startElName = startEl.getName();
                        startElLocalName = startElName.getLocalPart();
                        if (proxy && "proxyGrantingTicket".equals(startElLocalName)) {
                            event = eventReader.nextEvent();
                            assert event.isCharacters();
                            Characters chars = event.asCharacters();
                            pgtIou = chars.getData();
                            LOGGER.debug("XML parser found pgt: {}", pgtIou);
                        } else if ("user".equals(startElLocalName)) {
                            // move on to the body of the user tag
                            event = eventReader.nextEvent();
                            assert event.isCharacters();
                            Characters chars = event.asCharacters();
                            username = chars.getData();
                            LOGGER.debug("XML parser found user: {}", username);
                        } else {
                            LOGGER.error("Found unexpected element [{}] while inside 'authenticationSuccess'",
                                    startElName);
                            break;
                        }
                        if (username != null && (!proxy || pgtIou != null)) {
                            break;
                        }
                    }
                }
            }
        }
    } catch (XMLStreamException e) {
        LOGGER.error(e.getMessage(), e);
    }

    if (failureCode != null || failureMessage != null) {
        LOGGER.error("Error response from server code={} message={}", failureCode, failureMessage);
    }
    String pgt = pgts.get(pgtIou);
    if (pgt != null) {
        savePgt(username, pgt, pgtIou);
    } else {
        LOGGER.debug("Caching '{}' as the IOU for '{}'", pgtIou, username);
        pgtIOUs.put(pgtIou, username);
    }
    return username;
}

From source file:org.sdm.spa.WebService.java

/**
 * Get the URL address of the the location of the web service defined by the
 * given WSDL. Get the the namespace and binding information of the web
 * service using the given WSDL and methodName. Add a parameter to the call
 * object for each input part.Fill these parameters with the input values on
 * channels on the ports that correspond to them. Invoke the web service
 * using all the gathered information. Send the response of the call to the
 * result port./*from   w w w.  ja va  2s . co m*/
 * 
 * @exception IllegalActionException
 *                If there is no director.
 */
public void fire() throws IllegalActionException {

    super.fire();

    // triggerring the actor..
    if (startTrigger.getWidth() > 0) {
        for (int i = 0; i < startTrigger.getWidth(); i++)
            startTrigger.get(i);
    }

    _urlStr = ((StringToken) wsdlUrl.getToken()).stringValue();
    _methodNameStr = ((StringToken) methodName.getToken()).stringValue();

    _wsdlParser = new Parser();

    try {
        _wsdlParser.run(new String(_urlStr));
    } catch (Exception ex) {
        _debug("<EXCEPTION> There was an error while parsing the WSDL in fire for URL: " + _urlStr + " .\n" + ex
                + ". </EXCEPTION>");
        // GraphicalMessageHandler.message(
        _errorsStr += "\n" + ex.getMessage()
                + "Error in fire: There was an error while parsing the WSDL in the actor: " + this.getName();// );

        /*
         * The following exception is thrown and for the case when the web
         * service's server is down. The director SDF4WS catches the
         * exception thrown below and re-tries to get web service
         * access.After three re-trials the director finally switches over
         * to the same service but at a different server (if second server
         * is available)
         */

        GraphicalMessageHandler.message("\nWebService WSDL:" + _urlStr + " Not Responding");
        throw new IllegalActionException("\nWebService WSDL Not Responding.");

    }
    _getServiceBinding();
    try {
        SymbolTable symbolTable = _wsdlParser.getSymbolTable();
        BindingEntry bEntry = symbolTable.getBindingEntry(_binding.getQName());
        Parameters parameters = null;
        Iterator<?> iter = bEntry.getParameters().keySet().iterator();
        for (; iter.hasNext();) {
            final Operation operation = (Operation) iter.next();
            if (operation.getName().equals(_methodNameStr)) {
                parameters = (Parameters) bEntry.getParameters().get(operation);
                // Set output type
                if (parameters.returnParam == null) {
                    _returnMode = 1; // Get outputs into a map object!
                } else if (parameters.returnParam != null) {
                    _returnMode = 2; // Get the invoke result value as a
                                     // single value.
                }
                // Break out of the loop
                break;
            }
        }
    } catch (Exception ex) {
        _debug("<EXCEPTION>In fire when setting the return mode: " + ex + ". </EXCEPTION>");
        // GraphicalMessageHandler.message(
        _errorsStr += "\n" + ex.getMessage() + "There was an error when setting up the return mode of the web "
                + "service at: " + this.getName();// );
    }

    try {
        org.apache.axis.client.Service myServiceClient = new org.apache.axis.client.Service(_wsdlParser,
                _service.getQName());
        _call = myServiceClient.createCall(QName.valueOf(_portName), QName.valueOf(_methodNameStr));
        _debug(_call.getClass().getName() + "Call implementation");

        // KLS((org.apache.axis.client.Call) _call).setTimeout(new
        // Integer(600000));
        ((org.apache.axis.client.Call) _call).setTimeout(new Integer(timeout.stringValue()));

        // Add a parameter to the call object for each input part.
        List<?> inPortList = inputPortList();
        int numInPorts = inPortList.size();
        // _debug("<TRIGGER_FLAG_BEFORE_OBJECT_ARR>" + _triggerFlag +
        // "</TRIGGER_FLAG_BEFORE_OBJECT_ARR>");
        // if (_triggerFlag) {
        _objArr = new Object[numInPorts - 1];
        // }
        // else {
        // _objArr = new Object[numInPorts];
        // }
        Iterator<?> ports = inPortList.iterator();
        int i = 0;
        while (ports.hasNext()) {
            // Fill these parameters with the input values on channels on
            // the
            // ports that correspond to them.
            TypedIOPort p = (TypedIOPort) ports.next();
            _debug("<INPUT_PORT>" + p.getName() + "</INPUT_PORT>");
            if (p.getName().equals("startTrigger")) {
                _debug("Skipped the value of the trigger port in fire.");
            } else {

                PortParameter input = ((ParameterPort) p).getParameter();
                input.update();
                _objArr[i] = _getObjectFromToken(input.getToken());
                i++;
            }
        }
        for (int j = 0; j < i; j++) {
            _debug("_objArr[" + j + "]=" + _objArr[j]);
        }

        _debug("<OBJ_ARR_LENGTH> " + (new Integer(_objArr.length)).toString() + " </OBJ_ARR_LENGTH>");
        _debug("<USERNAME> " + userName.stringValue() + " </USERNAME>");
        _call.setProperty(Call.USERNAME_PROPERTY, userName.stringValue());
        _debug("<PASSWORD> " + password.stringValue() + " </PASSWORD>");
        _call.setProperty(Call.PASSWORD_PROPERTY, password.stringValue());

        _debug("Starting the invoke!");
        // Element invokeResult = (Element) call.invoke(objArr);
        Object invokeResult = _call.invoke(_objArr);
        _debug("Got results from the invoke...");
        List<?> outPortList = this.outputPortList();
        Iterator<?> oports = outPortList.iterator();
        _debug("<RETURN_MODE> " + new Integer(_returnMode).toString() + " </RETURN_MODE>");
        if (_returnMode == 2) {
            while (oports.hasNext()) {
                TypedIOPort po = (TypedIOPort) oports.next();
                if (!(po.getName().equals("clientExecErrors"))) {
                    _sendOutput(po, invokeResult);
                }
            }
        } else if (_returnMode == 1) {
            Map outParams = _call.getOutputParams();
            while (oports.hasNext()) {
                // Fill these parameters with the input values on
                // channels on the ports that correspond to them.
                TypedIOPort po = (TypedIOPort) oports.next();
                _debug("<OUTPUT_PORT>" + po.getName() + ", " + po.getType().toString() + "</OUTPUT_PORT>");
                try {
                    if (!(po.getName().equals("clientExecErrors"))) {
                        _sendOutput(po, outParams.get(new QName("", po.getName())));
                    }
                } catch (Exception ex) {
                    _debug("<EXCEPTION> There was an exception when sending the outputs." + " OutValue: "
                            + (String) org.apache.axis.utils.JavaUtils
                                    .convert(outParams.get(new QName("", po.getName())), java.lang.String.class)
                            + ". </EXCEPTION>");
                    // GraphicalMessageHandler.message(
                    _errorsStr += "\n" + ex.getMessage() + "\nThe error occured in the actor: " + this.getName()
                            + "\n Please look at the debugging details for this actor for "
                            + "more information.";// );
                }
            }
        }
    } catch (ServiceException se) {
        throw new IllegalActionException(this, se, "Service error.");
    } catch (java.rmi.RemoteException rex) {
        throw new IllegalActionException(this, rex, "Web service error.");
    }

    System.out.println(_errorsStr);
    if (!(_errorsStr.equals(""))) {
        clientExecErrors.broadcast(new StringToken(_errorsStr));
    } else {
        clientExecErrors.broadcast(new StringToken("NO ERRORS."));
    }
}

From source file:org.sdm.spa.WSWithComplexTypes.java

/**
 * Invoke the WSDL operation and return any results.
 * //from w ww . j  a va 2s.c  om
 * @param sbe
 *            a SOAPBodyElement containing data for input parameters
 * @return the result, if any
 */
private List<?> _invokeMethod(SOAPBodyElement sbe)
        throws IllegalActionException, ServiceException, RemoteException, SAXException {
    org.apache.axis.client.Service svcClient = new org.apache.axis.client.Service(_wsdlParser,
            _wsdlService.getQName());

    Call call = svcClient.createCall(QName.valueOf(_wsdlPort.getName()), QName.valueOf(_methodStr));

    // set username, password, timeout if not empty.

    String str = username.stringValue();
    if (!str.equals("")) {
        call.setProperty(Call.USERNAME_PROPERTY, str);
    }

    str = password.stringValue();
    if (!str.equals("")) {
        call.setProperty(Call.PASSWORD_PROPERTY, str);
    }

    str = timeout.stringValue();
    if (!str.equals("")) {
        // we can do this cast since we used an axis service
        // to create the call
        ((org.apache.axis.client.Call) call).setTimeout(new Integer(str));
    }

    if (_isDebugging || _debugging) {
        // attempt to print the request xml
        _debugMessage("Web Service REQUEST:");
        StringWriter writer = new StringWriter();
        XMLUtils.PrettyElementToWriter(sbe, writer);
        _debugMessage("\n" + writer.toString());
    }

    // invoke the call and return the results
    return (List<?>) call.invoke(new Object[] { sbe });
}

From source file:org.seedstack.seed.ws.internal.WSPlugin.java

private EndpointDefinition createEndpointDefinition(String endpoint, Configuration endpointConfiguration) {
    // Implementation class
    String implementation = endpointConfiguration.getString("implementation");
    if (implementation == null || implementation.isEmpty()) {
        throw SeedException.createNew(WSErrorCode.IMPLEMENTATION_CLASS_MISSING).put(ENDPOINT_NAME_ATTRIBUTE,
                endpoint);/*from w ww .j av a 2s .  com*/
    }

    Class<?> implementationClass;
    try {
        implementationClass = Class.forName(implementation);
    } catch (ClassNotFoundException e) {
        throw SeedException.wrap(e, WSErrorCode.UNABLE_TO_LOAD_IMPLEMENTATION_CLASS)
                .put(ENDPOINT_NAME_ATTRIBUTE, endpoint).put(IMPLEMENTATION_CLASS_ATTRIBUTE, implementation);
    }

    // External metadata
    MetadataReader metadataReader = null;
    String externalMetadata = endpointConfiguration.getString("external-metadata");
    if (externalMetadata != null) {
        metadataReader = ExternalMetadataFeature.builder().addResources(externalMetadata).build()
                .getMetadataReader(SeedReflectionUtils.findMostCompleteClassLoader(implementationClass), false);
    }

    EndpointFactory.verifyImplementorClass(implementationClass, metadataReader);

    // Service name
    String serviceName = endpointConfiguration.getString("service-name");
    QName serviceQName;
    if (serviceName == null || serviceName.isEmpty()) {
        WebService annotation = implementationClass.getAnnotation(WebService.class);
        if (annotation != null && !annotation.targetNamespace().isEmpty()
                && !annotation.serviceName().isEmpty()) {
            serviceQName = new QName(annotation.targetNamespace(), annotation.serviceName());
        } else {
            serviceQName = EndpointFactory.getDefaultServiceName(implementationClass, metadataReader);
        }
    } else {
        serviceQName = QName.valueOf(serviceName);
    }

    // Service port
    String portName = endpointConfiguration.getString("port-name");
    QName portQName;
    if (portName == null || portName.isEmpty()) {
        WebService annotation = implementationClass.getAnnotation(WebService.class);
        if (annotation != null && !annotation.targetNamespace().isEmpty() && !annotation.portName().isEmpty()) {
            portQName = new QName(annotation.targetNamespace(), annotation.portName());
        } else {
            portQName = EndpointFactory.getDefaultPortName(serviceQName, implementationClass, metadataReader);
        }
    } else {
        portQName = QName.valueOf(portName);
    }

    // Binding
    String binding = endpointConfiguration.getString("binding");
    if (binding != null) {
        binding = getBindingIdForToken(binding);
    }

    WSBinding wsBinding = createBinding(binding, implementationClass,
            endpointConfiguration.getBoolean("enable-mtom", null),
            endpointConfiguration.getInteger("mtom-treshold", null),
            endpointConfiguration.getString("data-binding-mode", null));

    // WSDL
    String wsdlPath = endpointConfiguration.getString("wsdl",
            EndpointFactory.getWsdlLocation(implementationClass, metadataReader));
    if (wsdlPath == null || wsdlPath.isEmpty()) {
        throw SeedException.createNew(WSErrorCode.WSDL_LOCATION_MISSING).put(ENDPOINT_NAME_ATTRIBUTE, endpoint)
                .put(IMPLEMENTATION_CLASS_ATTRIBUTE, implementation);
    }

    URL wsdlURL;
    try {
        wsdlURL = resourceLoader.getResource(wsdlPath);
    } catch (MalformedURLException e) {
        throw SeedException.wrap(e, WSErrorCode.UNABLE_TO_FIND_WSDL).put(ENDPOINT_NAME_ATTRIBUTE, endpoint)
                .put(WSDL_LOCATION_ATTRIBUTE, wsdlPath);
    }

    if (wsdlURL == null) {
        throw SeedException.createNew(WSErrorCode.UNABLE_TO_FIND_WSDL).put(ENDPOINT_NAME_ATTRIBUTE, endpoint)
                .put(WSDL_LOCATION_ATTRIBUTE, wsdlPath);
    }

    SDDocumentSource primaryWSDL = docs.get(wsdlURL.toExternalForm());
    assert primaryWSDL != null;

    // Entity resolver
    EntityResolver entityResolver;
    try {
        entityResolver = XmlUtil.createEntityResolver(resourceLoader.getCatalogFile());
    } catch (MalformedURLException e) {
        LOGGER.warn("Unable to create entity resolver", e);
        entityResolver = XmlUtil.createEntityResolver(null);
    }

    return new EndpointDefinition(implementationClass, true, serviceQName, portQName, wsBinding, primaryWSDL,
            entityResolver, false, endpointConfiguration.getString("url"), endpointConfiguration);
}