EndpointFactory.java revision 325
0N/A/*
0N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
661N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.xml.internal.ws.server;
0N/A
0N/Aimport com.sun.istack.internal.NotNull;
661N/Aimport com.sun.istack.internal.Nullable;
661N/Aimport com.sun.xml.internal.ws.api.BindingID;
0N/Aimport com.sun.xml.internal.ws.api.WSBinding;
0N/Aimport com.sun.xml.internal.ws.api.policy.PolicyResolverFactory;
0N/Aimport com.sun.xml.internal.ws.api.policy.PolicyResolver;
0N/Aimport com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
0N/Aimport com.sun.xml.internal.ws.api.server.*;
661N/Aimport com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
0N/Aimport com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver;
661N/Aimport com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver.Parser;
0N/Aimport com.sun.xml.internal.ws.api.wsdl.writer.WSDLGeneratorExtension;
0N/Aimport com.sun.xml.internal.ws.binding.BindingImpl;
0N/Aimport com.sun.xml.internal.ws.binding.SOAPBindingImpl;
661N/Aimport com.sun.xml.internal.ws.binding.WebServiceFeatureList;
0N/Aimport com.sun.xml.internal.ws.model.AbstractSEIModelImpl;
0N/Aimport com.sun.xml.internal.ws.model.RuntimeModeler;
0N/Aimport com.sun.xml.internal.ws.model.SOAPSEIModel;
0N/Aimport com.sun.xml.internal.ws.model.wsdl.WSDLModelImpl;
0N/Aimport com.sun.xml.internal.ws.model.wsdl.WSDLPortImpl;
0N/Aimport com.sun.xml.internal.ws.model.wsdl.WSDLServiceImpl;
0N/Aimport com.sun.xml.internal.ws.resources.ServerMessages;
0N/Aimport com.sun.xml.internal.ws.server.provider.ProviderInvokerTube;
0N/Aimport com.sun.xml.internal.ws.server.sei.SEIInvokerTube;
0N/Aimport com.sun.xml.internal.ws.util.HandlerAnnotationInfo;
0N/Aimport com.sun.xml.internal.ws.util.HandlerAnnotationProcessor;
0N/Aimport com.sun.xml.internal.ws.util.ServiceConfigurationError;
661N/Aimport com.sun.xml.internal.ws.util.ServiceFinder;
0N/Aimport com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser;
0N/Aimport com.sun.xml.internal.ws.wsdl.writer.WSDLGenerator;
0N/Aimport com.sun.xml.internal.ws.policy.PolicyMap;
0N/Aimport com.sun.xml.internal.ws.policy.jaxws.PolicyUtil;
0N/Aimport org.xml.sax.EntityResolver;
0N/Aimport org.xml.sax.SAXException;
0N/A
0N/Aimport javax.jws.WebService;
661N/Aimport javax.xml.namespace.QName;
0N/Aimport javax.xml.stream.XMLStreamException;
0N/Aimport javax.xml.ws.Provider;
0N/Aimport javax.xml.ws.WebServiceException;
0N/Aimport javax.xml.ws.WebServiceProvider;
0N/Aimport javax.xml.ws.WebServiceFeature;
0N/Aimport javax.xml.ws.soap.SOAPBinding;
0N/Aimport java.io.IOException;
0N/Aimport java.net.URL;
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Collection;
0N/Aimport java.util.HashMap;
0N/Aimport java.util.List;
0N/Aimport java.util.Map;
0N/Aimport java.util.logging.Logger;
0N/A
0N/A/**
0N/A * Entry point to the JAX-WS RI server-side runtime.
0N/A *
0N/A * @author Kohsuke Kawaguchi
0N/A * @author Jitendra Kotamraju
0N/A */
0N/Apublic class EndpointFactory {
0N/A
0N/A /**
0N/A * Implements {@link WSEndpoint#create}.
0N/A *
0N/A * No need to take WebServiceContext implementation. When InvokerPipe is
0N/A * instantiated, it calls InstanceResolver to set up a WebServiceContext.
0N/A * We shall only take delegate to getUserPrincipal and isUserInRole from adapter.
0N/A *
0N/A * <p>
0N/A * Nobody else should be calling this method.
0N/A */
0N/A public static <T> WSEndpoint<T> createEndpoint(
0N/A Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker,
0N/A @Nullable QName serviceName, @Nullable QName portName,
0N/A @Nullable Container container, @Nullable WSBinding binding,
0N/A @Nullable SDDocumentSource primaryWsdl,
0N/A @Nullable Collection<? extends SDDocumentSource> metadata,
0N/A EntityResolver resolver, boolean isTransportSynchronous) {
0N/A
0N/A if(implType ==null)
0N/A throw new IllegalArgumentException();
0N/A
0N/A verifyImplementorClass(implType);
0N/A
0N/A if (invoker == null) {
0N/A invoker = InstanceResolver.createDefault(implType).createInvoker();
0N/A }
0N/A
0N/A List<SDDocumentSource> md = new ArrayList<SDDocumentSource>();
0N/A if(metadata!=null)
0N/A md.addAll(metadata);
0N/A
0N/A if(primaryWsdl!=null && !md.contains(primaryWsdl))
0N/A md.add(primaryWsdl);
0N/A
0N/A if(container==null)
0N/A container = ContainerResolver.getInstance().getContainer();
0N/A
0N/A if(serviceName==null)
0N/A serviceName = getDefaultServiceName(implType);
0N/A
0N/A if(portName==null)
0N/A portName = getDefaultPortName(serviceName,implType);
0N/A
0N/A {// error check
0N/A String serviceNS = serviceName.getNamespaceURI();
0N/A String portNS = portName.getNamespaceURI();
0N/A if (!serviceNS.equals(portNS)) {
0N/A throw new ServerRtException("wrong.tns.for.port",portNS, serviceNS);
0N/A }
0N/A }
0N/A
0N/A // setting a default binding
0N/A if (binding == null)
0N/A binding = BindingImpl.create(BindingID.parse(implType));
0N/A
0N/A if (primaryWsdl != null) {
0N/A verifyPrimaryWSDL(primaryWsdl, serviceName);
0N/A }
0N/A
0N/A QName portTypeName = null;
0N/A if (implType.getAnnotation(WebServiceProvider.class)==null) {
0N/A portTypeName = RuntimeModeler.getPortTypeName(implType);
0N/A }
0N/A
0N/A // Categorises the documents as WSDL, Schema etc
661N/A List<SDDocumentImpl> docList = categoriseMetadata(md, serviceName, portTypeName);
0N/A // Finds the primary WSDL and makes sure that metadata doesn't have
0N/A // two concrete or abstract WSDLs
0N/A SDDocumentImpl primaryDoc = findPrimary(docList);
0N/A
0N/A InvokerTube terminal;
0N/A WSDLPortImpl wsdlPort = null;
0N/A AbstractSEIModelImpl seiModel = null;
0N/A // create WSDL model
0N/A if (primaryDoc != null) {
0N/A wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container);
661N/A }
661N/A
0N/A WebServiceFeatureList features=((BindingImpl)binding).getFeatures();
0N/A features.parseAnnotations(implType);
0N/A PolicyMap policyMap = null;
0N/A // create terminal pipe that invokes the application
0N/A if (implType.getAnnotation(WebServiceProvider.class)!=null) {
0N/A //TODO incase of Provider, provide a way to User for complete control of the message processing by giving
0N/A // ability to turn off the WSDL/Policy based features and its associated tubes.
0N/A
0N/A //Even in case of Provider, merge all features configured via WSDL/Policy or deployment configuration
0N/A Iterable<WebServiceFeature> configFtrs;
0N/A if(wsdlPort != null) {
661N/A policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
0N/A //Merge features from WSDL and other policy configuration
661N/A configFtrs = wsdlPort.getFeatures();
0N/A } else {
661N/A //No WSDL, so try to merge features from Policy configuration
0N/A policyMap = PolicyResolverFactory.create().resolve(
661N/A new PolicyResolver.ServerContext(null, container, implType, false));
0N/A configFtrs = PolicyUtil.getPortScopedFeatures(policyMap,serviceName,portName);
661N/A }
0N/A features.mergeFeatures(configFtrs, true);
661N/A terminal = ProviderInvokerTube.create(implType,binding,invoker);
0N/A } else {
0N/A // Create runtime model for non Provider endpoints
0N/A seiModel = createSEIModel(wsdlPort, implType, serviceName, portName, binding);
0N/A if(binding instanceof SOAPBindingImpl){
0N/A //set portKnownHeaders on Binding, so that they can be used for MU processing
0N/A ((SOAPBindingImpl)binding).setPortKnownHeaders(
0N/A ((SOAPSEIModel)seiModel).getKnownHeaders());
0N/A }
0N/A // Generate WSDL for SEI endpoints(not for Provider endpoints)
0N/A if (primaryDoc == null) {
0N/A primaryDoc = generateWSDL(binding, seiModel, docList, container, implType);
0N/A // create WSDL model
0N/A wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container);
0N/A seiModel.freeze(wsdlPort);
0N/A }
0N/A policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
0N/A // New Features might have been added in WSDL through Policy.
0N/A //Merge features from WSDL and other policy configuration
0N/A // This sets only the wsdl features that are not already set(enabled/disabled)
0N/A features.mergeFeatures(wsdlPort.getFeatures(), true);
0N/A terminal= new SEIInvokerTube(seiModel,invoker,binding);
0N/A }
0N/A
0N/A // Process @HandlerChain, if handler-chain is not set via Deployment Descriptor
0N/A if (processHandlerAnnotation) {
0N/A processHandlerAnnotation(binding, implType, serviceName, portName);
0N/A }
0N/A // Selects only required metadata for this endpoint from the passed-in metadata
0N/A if (primaryDoc != null) {
0N/A docList = findMetadataClosure(primaryDoc, docList);
0N/A }
0N/A ServiceDefinitionImpl serviceDefiniton = (primaryDoc != null) ? new ServiceDefinitionImpl(docList, primaryDoc) : null;
0N/A
0N/A return new WSEndpointImpl<T>(serviceName, portName, binding,container,seiModel,wsdlPort,implType, serviceDefiniton,terminal, isTransportSynchronous, policyMap);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Goes through the original metadata documents and collects the required ones.
0N/A * This done traversing from primary WSDL and its imports until it builds a
0N/A * complete set of documents(transitive closure) for the endpoint.
0N/A *
0N/A * @param primaryDoc primary WSDL doc
0N/A * @param docList complete metadata
0N/A * @return new metadata that doesn't contain extraneous documnets.
0N/A */
0N/A private static List<SDDocumentImpl> findMetadataClosure(SDDocumentImpl primaryDoc, List<SDDocumentImpl> docList) {
0N/A // create a map for old metadata
0N/A Map<String, SDDocumentImpl> oldMap = new HashMap<String, SDDocumentImpl>();
0N/A for(SDDocumentImpl doc : docList) {
0N/A oldMap.put(doc.getSystemId().toString(), doc);
661N/A }
0N/A // create a map for new metadata
0N/A Map<String, SDDocumentImpl> newMap = new HashMap<String, SDDocumentImpl>();
0N/A newMap.put(primaryDoc.getSystemId().toString(), primaryDoc);
0N/A
0N/A List<String> remaining = new ArrayList<String>();
0N/A remaining.addAll(primaryDoc.getImports());
661N/A while(!remaining.isEmpty()) {
0N/A String url = remaining.remove(0);
661N/A SDDocumentImpl doc = oldMap.get(url);
661N/A if (doc == null) {
661N/A // old metadata doesn't have this imported doc, may be external
661N/A continue;
661N/A }
0N/A // Check if new metadata already contains this doc
0N/A if (!newMap.containsKey(url)) {
0N/A newMap.put(url, doc);
0N/A remaining.addAll(doc.getImports());
0N/A }
0N/A }
0N/A List<SDDocumentImpl> newMetadata = new ArrayList<SDDocumentImpl>();
0N/A newMetadata.addAll(newMap.values());
0N/A return newMetadata;
0N/A }
0N/A
0N/A private static <T> void processHandlerAnnotation(WSBinding binding, Class<T> implType, QName serviceName, QName portName) {
661N/A HandlerAnnotationInfo chainInfo =
661N/A HandlerAnnotationProcessor.buildHandlerInfo(
661N/A implType, serviceName, portName, binding);
661N/A if (chainInfo != null) {
661N/A binding.setHandlerChain(chainInfo.getHandlers());
661N/A if (binding instanceof SOAPBinding) {
661N/A ((SOAPBinding) binding).setRoles(chainInfo.getRoles());
661N/A }
661N/A }
661N/A
661N/A }
661N/A
661N/A /**
661N/A * Verifies if the endpoint implementor class has @WebService or @WebServiceProvider
661N/A * annotation
661N/A *
661N/A * @return
661N/A * true if it is a Provider or AsyncProvider endpoint
661N/A * false otherwise
0N/A * @throws java.lang.IllegalArgumentException
0N/A * If it doesn't have any one of @WebService or @WebServiceProvider
0N/A * If it has both @WebService and @WebServiceProvider annotations
0N/A */
0N/A public static boolean verifyImplementorClass(Class<?> clz) {
0N/A WebServiceProvider wsProvider = clz.getAnnotation(WebServiceProvider.class);
0N/A WebService ws = clz.getAnnotation(WebService.class);
0N/A if (wsProvider == null && ws == null) {
0N/A throw new IllegalArgumentException(clz +" has neither @WebService nor @WebServiceProvider annotation");
0N/A }
0N/A if (wsProvider != null && ws != null) {
0N/A throw new IllegalArgumentException(clz +" has both @WebService and @WebServiceProvider annotations");
0N/A }
0N/A if (wsProvider != null) {
0N/A if (Provider.class.isAssignableFrom(clz) || AsyncProvider.class.isAssignableFrom(clz)) {
0N/A return true;
0N/A }
0N/A throw new IllegalArgumentException(clz +" doesn't implement Provider or AsyncProvider interface");
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A
0N/A private static AbstractSEIModelImpl createSEIModel(WSDLPort wsdlPort,
0N/A Class<?> implType, @NotNull QName serviceName, @NotNull QName portName, WSBinding binding) {
0N/A
0N/A RuntimeModeler rap;
0N/A // Create runtime model for non Provider endpoints
0N/A
0N/A // wsdlPort will be null, means we will generate WSDL. Hence no need to apply
0N/A // bindings or need to look in the WSDL
0N/A if(wsdlPort == null){
0N/A rap = new RuntimeModeler(implType,serviceName, binding.getBindingId(), binding.getFeatures().toArray());
0N/A } else {
0N/A /*
0N/A This not needed anymore as wsdlFeatures are merged later anyway
0N/A and so is the MTOMFeature.
0N/A applyEffectiveMtomSetting(wsdlPort.getBinding(), binding);
0N/A */
0N/A //now we got the Binding so lets build the model
0N/A rap = new RuntimeModeler(implType, serviceName, (WSDLPortImpl)wsdlPort, binding.getFeatures().toArray());
0N/A }
0N/A rap.setClassLoader(implType.getClassLoader());
0N/A rap.setPortName(portName);
0N/A return rap.buildRuntimeModel();
0N/A }
0N/A
661N/A /**
661N/A *Set the mtom enable setting from wsdl model (mtom policy assertion) on to @link WSBinding} if DD has
661N/A * not already set it on BindingID. Also check conflicts.
661N/A */
661N/A /*
661N/A private static void applyEffectiveMtomSetting(WSDLBoundPortType wsdlBinding, WSBinding binding){
661N/A if(wsdlBinding.isMTOMEnabled()){
661N/A BindingID bindingId = binding.getBindingId();
661N/A if(bindingId.isMTOMEnabled() == null){
661N/A binding.setMTOMEnabled(true);
661N/A }else if (bindingId.isMTOMEnabled() != null && bindingId.isMTOMEnabled() == Boolean.FALSE){
661N/A //TODO: i18N
0N/A throw new ServerRtException("Deployment failed! Mtom policy assertion in WSDL is enabled whereas the deplyment descriptor setting wants to disable it!");
}
}
}
*/
/**
* If service name is not already set via DD or programmatically, it uses
* annotations {@link WebServiceProvider}, {@link WebService} on implementorClass to get PortName.
*
* @return non-null service name
*/
public static @NotNull QName getDefaultServiceName(Class<?> implType) {
QName serviceName;
WebServiceProvider wsProvider = implType.getAnnotation(WebServiceProvider.class);
if (wsProvider!=null) {
String tns = wsProvider.targetNamespace();
String local = wsProvider.serviceName();
serviceName = new QName(tns, local);
} else {
serviceName = RuntimeModeler.getServiceName(implType);
}
assert serviceName != null;
return serviceName;
}
/**
* If portName is not already set via DD or programmatically, it uses
* annotations on implementorClass to get PortName.
*
* @return non-null port name
*/
public static @NotNull QName getDefaultPortName(QName serviceName, Class<?> implType) {
QName portName;
WebServiceProvider wsProvider = implType.getAnnotation(WebServiceProvider.class);
if (wsProvider!=null) {
String tns = wsProvider.targetNamespace();
String local = wsProvider.portName();
portName = new QName(tns, local);
} else {
portName = RuntimeModeler.getPortName(implType, serviceName.getNamespaceURI());
}
assert portName != null;
return portName;
}
/**
* Returns the wsdl from @WebService, or @WebServiceProvider annotation using
* wsdlLocation element.
*
* @param implType
* endpoint implementation class
* make sure that you called {@link #verifyImplementorClass} on it.
* @return wsdl if there is wsdlLocation, else null
*/
public static @Nullable String getWsdlLocation(Class<?> implType) {
String wsdl;
WebService ws = implType.getAnnotation(WebService.class);
if (ws != null) {
wsdl = ws.wsdlLocation();
} else {
WebServiceProvider wsProvider = implType.getAnnotation(WebServiceProvider.class);
assert wsProvider != null;
wsdl = wsProvider.wsdlLocation();
}
if (wsdl.length() < 1) {
wsdl = null;
}
return wsdl;
}
/**
* Generates the WSDL and XML Schema for the endpoint if necessary
* It generates WSDL only for SOAP1.1, and for XSOAP1.2 bindings
*/
private static SDDocumentImpl generateWSDL(WSBinding binding, AbstractSEIModelImpl seiModel, List<SDDocumentImpl> docs,
Container container, Class implType) {
BindingID bindingId = binding.getBindingId();
if (!bindingId.canGenerateWSDL()) {
throw new ServerRtException("can.not.generate.wsdl", bindingId);
}
if (bindingId.toString().equals(SOAPBindingImpl.X_SOAP12HTTP_BINDING)) {
String msg = ServerMessages.GENERATE_NON_STANDARD_WSDL();
logger.warning(msg);
}
// Generate WSDL and schema documents using runtime model
WSDLGenResolver wsdlResolver = new WSDLGenResolver(docs,seiModel.getServiceQName(),seiModel.getPortTypeName());
WSDLGenerator wsdlGen = new WSDLGenerator(seiModel, wsdlResolver, binding, container, implType, false,
ServiceFinder.find(WSDLGeneratorExtension.class).toArray());
wsdlGen.doGeneration();
return wsdlResolver.updateDocs();
}
/**
* Builds {@link SDDocumentImpl} from {@link SDDocumentSource}.
*/
private static List<SDDocumentImpl> categoriseMetadata(
List<SDDocumentSource> src, QName serviceName, QName portTypeName) {
List<SDDocumentImpl> r = new ArrayList<SDDocumentImpl>(src.size());
for (SDDocumentSource doc : src) {
r.add(SDDocumentImpl.create(doc,serviceName,portTypeName));
}
return r;
}
/**
* Verifies whether the given primaryWsdl contains the given serviceName.
* If the WSDL doesn't have the service, it throws an WebServiceException.
*/
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
if (!(primaryDoc instanceof SDDocument.WSDL)) {
throw new WebServiceException(primaryWsdl.getSystemId()+
" is not a WSDL. But it is passed as a primary WSDL");
}
SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
if (!wsdlDoc.hasService()) {
if(wsdlDoc.getAllServices().isEmpty())
throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
" since it doesn't have Service "+serviceName);
else
throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
+" has the following services "+wsdlDoc.getAllServices()
+" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
}
}
/**
* Finds the primary WSDL document from the list of metadata documents. If
* there are two metadata documents that qualify for primary, it throws an
* exception. If there are two metadata documents that qualify for porttype,
* it throws an exception.
*
* @return primay wsdl document, null if is not there in the docList
*
*/
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
SDDocumentImpl primaryDoc = null;
boolean foundConcrete = false;
boolean foundAbstract = false;
for(SDDocumentImpl doc : docList) {
if (doc instanceof SDDocument.WSDL) {
SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
if (wsdlDoc.hasService()) {
primaryDoc = doc;
if (foundConcrete) {
throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
}
foundConcrete = true;
}
if (wsdlDoc.hasPortType()) {
if (foundAbstract) {
throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
}
foundAbstract = true;
}
}
}
return primaryDoc;
}
/**
* Parses the primary WSDL and returns the {@link WSDLPort} for the given service and port names
*
* @param primaryWsdl Primary WSDL
* @param metadata it may contain imported WSDL and schema documents
* @param serviceName service name in wsdl
* @param portName port name in WSDL
* @param container container in which this service is running
* @return non-null wsdl port object
*/
private static @NotNull WSDLPortImpl getWSDLPort(SDDocumentSource primaryWsdl, List<? extends SDDocumentSource> metadata,
@NotNull QName serviceName, @NotNull QName portName, Container container) {
URL wsdlUrl = primaryWsdl.getSystemId();
try {
// TODO: delegate to another entity resolver
WSDLModelImpl wsdlDoc = RuntimeWSDLParser.parse(
new Parser(primaryWsdl), new EntityResolverImpl(metadata),
false, container, ServiceFinder.find(WSDLParserExtension.class).toArray());
if(wsdlDoc.getServices().size() == 0) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_NOSERVICE_IN_WSDLMODEL(wsdlUrl));
}
WSDLServiceImpl wsdlService = wsdlDoc.getService(serviceName);
if (wsdlService == null) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_INCORRECTSERVICE(serviceName,wsdlUrl));
}
WSDLPortImpl wsdlPort = wsdlService.get(portName);
if (wsdlPort == null) {
throw new ServerRtException(ServerMessages.localizableRUNTIME_PARSER_WSDL_INCORRECTSERVICEPORT(serviceName, portName, wsdlUrl));
}
return wsdlPort;
} catch (IOException e) {
throw new ServerRtException("runtime.parser.wsdl", wsdlUrl,e);
} catch (XMLStreamException e) {
throw new ServerRtException("runtime.saxparser.exception", e.getMessage(), e.getLocation(), e);
} catch (SAXException e) {
throw new ServerRtException("runtime.parser.wsdl", wsdlUrl,e);
} catch (ServiceConfigurationError e) {
throw new ServerRtException("runtime.parser.wsdl", wsdlUrl,e);
}
}
/**
* {@link XMLEntityResolver} that can resolve to {@link SDDocumentSource}s.
*/
private static final class EntityResolverImpl implements XMLEntityResolver {
private Map<String,SDDocumentSource> metadata = new HashMap<String,SDDocumentSource>();
public EntityResolverImpl(List<? extends SDDocumentSource> metadata) {
for (SDDocumentSource doc : metadata) {
this.metadata.put(doc.getSystemId().toExternalForm(),doc);
}
}
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
if (systemId != null) {
SDDocumentSource doc = metadata.get(systemId);
if (doc != null)
return new Parser(doc);
}
return null;
}
}
private static final Logger logger = Logger.getLogger(
com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server.endpoint");
}