001: package org.objectweb.celtix.wsdl;
002:
003: import java.net.URL;
004: import java.util.ArrayList;
005: import java.util.List;
006: import java.util.Map;
007: import java.util.WeakHashMap;
008: import java.util.logging.Level;
009: import java.util.logging.Logger;
010:
011: import javax.jws.WebService;
012: import javax.wsdl.Definition;
013: import javax.wsdl.Import;
014: import javax.wsdl.Port;
015: import javax.wsdl.Service;
016: import javax.wsdl.Types;
017: import javax.wsdl.WSDLException;
018: import javax.xml.XMLConstants;
019: import javax.xml.bind.JAXBElement;
020: import javax.xml.namespace.QName;
021: import javax.xml.transform.Source;
022: import javax.xml.transform.Transformer;
023: import javax.xml.transform.TransformerConfigurationException;
024: import javax.xml.transform.TransformerException;
025: import javax.xml.transform.TransformerFactory;
026: import javax.xml.transform.dom.DOMResult;
027: import javax.xml.transform.dom.DOMSource;
028: import javax.xml.transform.stream.StreamSource;
029: import javax.xml.validation.Schema;
030: import javax.xml.validation.SchemaFactory;
031: import javax.xml.ws.WebServiceException;
032: import javax.xml.ws.WebServiceProvider;
033:
034: import org.w3c.dom.Document;
035: import org.w3c.dom.Element;
036: import org.w3c.dom.Node;
037: import org.xml.sax.SAXException;
038:
039: import org.objectweb.celtix.common.logging.LogUtils;
040: import org.objectweb.celtix.jaxb.JAXBUtils;
041: import org.objectweb.celtix.ws.addressing.AttributedURIType;
042: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
043: import org.objectweb.celtix.ws.addressing.MetadataType;
044: import org.objectweb.celtix.ws.addressing.ObjectFactory;
045: import org.objectweb.celtix.ws.addressing.wsdl.AttributedQNameType;
046: import org.objectweb.celtix.ws.addressing.wsdl.ServiceNameType;
047:
048: /**
049: * Provides utility methods for obtaining endpoint references, wsdl definitions, etc.
050: */
051: public final class EndpointReferenceUtils {
052:
053: static WeakHashMap<Definition, Schema> schemaMap = new WeakHashMap<Definition, Schema>();
054:
055: private static final Logger LOG = LogUtils
056: .getL7dLogger(EndpointReferenceUtils.class);
057:
058: private static final QName WSDL_LOCATION = new QName(
059: "http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation");
060: private static final Transformer XML_TRANSFORMER;
061: static {
062: Transformer transformer = null;
063: try {
064: TransformerFactory tf = TransformerFactory.newInstance();
065: transformer = tf.newTransformer();
066: } catch (TransformerConfigurationException tce) {
067: throw new WebServiceException(
068: "Could not create transformer", tce);
069: }
070: XML_TRANSFORMER = transformer;
071: }
072:
073: private EndpointReferenceUtils() {
074: // Utility class - never constructed
075: }
076:
077: /**
078: * Sets the service and port name of the provided endpoint reference.
079: * @param ref the endpoint reference.
080: * @param serviceName the name of service.
081: * @param portName the port name.
082: */
083: public static void setServiceAndPortName(EndpointReferenceType ref,
084: QName serviceName, String portName)
085: throws WebServiceException {
086: if (null != serviceName) {
087: ServiceNameType serviceNameType = new ServiceNameType();
088: serviceNameType.setValue(serviceName);
089: serviceNameType.setEndpointName(portName);
090: org.objectweb.celtix.ws.addressing.wsdl.ObjectFactory objectFactory = new org.objectweb.celtix.ws.addressing.wsdl.ObjectFactory();
091: JAXBElement<ServiceNameType> jaxbElement = objectFactory
092: .createServiceName(serviceNameType);
093:
094: MetadataType mt = ref.getMetadata();
095: if (null == mt) {
096: mt = new MetadataType();
097: ref.setMetadata(mt);
098: }
099:
100: mt.getAny().add(jaxbElement);
101: }
102: }
103:
104: /**
105: * Gets the service name of the provided endpoint reference.
106: * @param ref the endpoint reference.
107: * @return the service name.
108: */
109: public static QName getServiceName(EndpointReferenceType ref) {
110: MetadataType metadata = ref.getMetadata();
111: if (metadata != null) {
112: for (Object obj : metadata.getAny()) {
113: if (obj instanceof Element) {
114: Node node = (Element) obj;
115: if (node
116: .getNamespaceURI()
117: .equals(
118: "http://www.w3.org/2005/08/addressing/wsdl")
119: && node.getLocalName()
120: .equals("ServiceName")) {
121: String content = node.getTextContent();
122: String namespaceURI = node.getFirstChild()
123: .getNamespaceURI();
124: String service = content;
125: if (content.contains(":")) {
126: namespaceURI = getNameSpaceUri(node,
127: content, namespaceURI);
128: service = getService(content);
129: } else {
130: Node nodeAttr = node.getAttributes()
131: .getNamedItem("xmlns");
132: namespaceURI = nodeAttr.getNodeValue();
133: }
134:
135: return new QName(namespaceURI, service);
136: }
137: } else if (obj instanceof JAXBElement) {
138: Object val = ((JAXBElement) obj).getValue();
139: if (val instanceof ServiceNameType) {
140: return ((ServiceNameType) val).getValue();
141: }
142: } else if (obj instanceof ServiceNameType) {
143: return ((ServiceNameType) obj).getValue();
144: }
145: }
146: }
147: return null;
148: }
149:
150: /**
151: * Gets the port name of the provided endpoint reference.
152: * @param ref the endpoint reference.
153: * @return the port name.
154: */
155: public static String getPortName(EndpointReferenceType ref) {
156: MetadataType metadata = ref.getMetadata();
157: if (metadata != null) {
158: for (Object obj : metadata.getAny()) {
159: if (obj instanceof Element) {
160: Node node = (Element) obj;
161: if (node
162: .getNamespaceURI()
163: .equals(
164: "http://www.w3.org/2005/08/addressing/wsdl")
165: && node.getNodeName().contains(
166: "ServiceName")) {
167: return node.getAttributes().getNamedItem(
168: "EndpointName").getTextContent();
169: }
170: } else if (obj instanceof JAXBElement) {
171: Object val = ((JAXBElement) obj).getValue();
172: if (val instanceof ServiceNameType) {
173: return ((ServiceNameType) val)
174: .getEndpointName();
175: }
176: } else if (obj instanceof ServiceNameType) {
177: return ((ServiceNameType) obj).getEndpointName();
178: }
179: }
180: }
181: return null;
182: }
183:
184: public static void setInterfaceName(EndpointReferenceType ref,
185: QName portTypeName) {
186: if (null != portTypeName) {
187: AttributedQNameType interfaceNameType = new AttributedQNameType();
188:
189: interfaceNameType.setValue(portTypeName);
190:
191: org.objectweb.celtix.ws.addressing.wsdl.ObjectFactory objectFactory = new org.objectweb.celtix.ws.addressing.wsdl.ObjectFactory();
192: JAXBElement<AttributedQNameType> jaxbElement = objectFactory
193: .createInterfaceName(interfaceNameType);
194:
195: MetadataType mt = ref.getMetadata();
196: if (null == mt) {
197: mt = new MetadataType();
198: ref.setMetadata(mt);
199: }
200: mt.getAny().add(jaxbElement);
201: }
202: }
203:
204: public static QName getInterfaceName(EndpointReferenceType ref) {
205: MetadataType metadata = ref.getMetadata();
206: if (metadata != null) {
207: for (Object obj : metadata.getAny()) {
208: if (obj instanceof Element) {
209: Node node = (Element) obj;
210: System.out.println(node.getNamespaceURI() + ":"
211: + node.getNodeName());
212: if (node
213: .getNamespaceURI()
214: .equals(
215: "http://www.w3.org/2005/08/addressing/wsdl")
216: && node.getNodeName().contains(
217: "InterfaceName")) {
218:
219: String content = node.getTextContent();
220: String namespaceURI = node.getFirstChild()
221: .getNamespaceURI();
222: //String service = content;
223: if (content.contains(":")) {
224: namespaceURI = getNameSpaceUri(node,
225: content, namespaceURI);
226: content = getService(content);
227: } else {
228: Node nodeAttr = node.getAttributes()
229: .getNamedItem("xmlns");
230: namespaceURI = nodeAttr.getNodeValue();
231: }
232:
233: return new QName(namespaceURI, content);
234: }
235: } else if (obj instanceof JAXBElement) {
236: Object val = ((JAXBElement) obj).getValue();
237: if (val instanceof AttributedQNameType) {
238: return ((AttributedQNameType) val).getValue();
239: }
240: } else if (obj instanceof AttributedQNameType) {
241: return ((AttributedQNameType) obj).getValue();
242: }
243: }
244: }
245:
246: return null;
247: }
248:
249: private static void setWSDLLocation(EndpointReferenceType ref,
250: String... wsdlLocation) {
251:
252: MetadataType metadata = ref.getMetadata();
253: if (null == metadata) {
254: metadata = new MetadataType();
255: ref.setMetadata(metadata);
256: }
257:
258: //wsdlLocation attribute is a list of anyURI.
259: StringBuffer strBuf = new StringBuffer();
260: for (String str : wsdlLocation) {
261: strBuf.append(str);
262: strBuf.append(" ");
263: }
264:
265: metadata.getOtherAttributes().put(WSDL_LOCATION,
266: strBuf.toString().trim());
267: }
268:
269: public static String getWSDLLocation(EndpointReferenceType ref) {
270: String wsdlLocation = null;
271: MetadataType metadata = ref.getMetadata();
272:
273: if (metadata != null) {
274: wsdlLocation = metadata.getOtherAttributes().get(
275: WSDL_LOCATION);
276: }
277:
278: if (null == wsdlLocation) {
279: return null;
280: }
281:
282: //TODO The wsdlLocation inserted should be a valid URI
283: //before doing a split. So temporarily return the string
284: //return wsdlLocation.split(" ");
285: return wsdlLocation;
286: }
287:
288: /**
289: * Sets the metadata on the provided endpoint reference.
290: * @param ref the endpoint reference.
291: * @param the list of metadata source.
292: */
293: public static void setMetadata(EndpointReferenceType ref,
294: List<Source> metadata) {
295: if (null != ref) {
296: MetadataType mt = ref.getMetadata();
297: if (null == mt) {
298: mt = new MetadataType();
299: ref.setMetadata(mt);
300: }
301: List<Object> anyList = mt.getAny();
302: try {
303: for (Source source : metadata) {
304: Node node = null;
305: boolean doTransform = true;
306: if (source instanceof StreamSource) {
307: StreamSource ss = (StreamSource) source;
308: if (null == ss.getInputStream()
309: && null == ss.getReader()) {
310: setWSDLLocation(ref, ss.getSystemId());
311: doTransform = false;
312: }
313: } else if (source instanceof DOMSource) {
314: node = ((DOMSource) node).getNode();
315: doTransform = false;
316: }
317:
318: if (doTransform) {
319: DOMResult domResult = new DOMResult();
320: domResult.setSystemId(source.getSystemId());
321:
322: XML_TRANSFORMER.transform(source, domResult);
323:
324: node = domResult.getNode();
325: }
326:
327: if (null != node) {
328: if (node instanceof Document) {
329: ((Document) node).setDocumentURI(source
330: .getSystemId());
331: node = node.getFirstChild();
332: }
333:
334: while (node.getNodeType() != Node.ELEMENT_NODE) {
335: node = node.getNextSibling();
336: }
337:
338: anyList.add(node);
339: }
340: }
341: } catch (TransformerException te) {
342: throw new WebServiceException(
343: "Populating metadata in EPR failed", te);
344: }
345: }
346: }
347:
348: /**
349: * Gets the WSDL definition for the provided endpoint reference.
350: * @param manager - the WSDL manager
351: * @param ref - the endpoint reference
352: * @return Definition the wsdl definition
353: * @throws WSDLException
354: */
355: public static Definition getWSDLDefinition(WSDLManager manager,
356: EndpointReferenceType ref) throws WSDLException {
357:
358: if (null == manager) {
359: return null;
360: }
361:
362: MetadataType metadata = ref.getMetadata();
363: String location = getWSDLLocation(ref);
364:
365: if (null != location) {
366: //Pick up the first url to obtain the wsdl defintion
367: return manager.getDefinition(location);
368: }
369:
370: for (Object obj : metadata.getAny()) {
371: if (obj instanceof Element) {
372: Element el = (Element) obj;
373: if ("http://schemas.xmlsoap.org/wsdl/".equals(el
374: .getNamespaceURI())
375: && "definitions".equals(el.getLocalName())) {
376: return manager.getDefinition(el);
377: }
378: }
379: }
380:
381: QName portTypeName = getInterfaceName(ref);
382: if (null != portTypeName) {
383:
384: StringBuffer seiName = new StringBuffer();
385: seiName.append(JAXBUtils.namespaceURIToPackage(portTypeName
386: .getNamespaceURI()));
387: seiName.append(".");
388: seiName.append(JAXBUtils
389: .nameToIdentifier(portTypeName.getLocalPart(),
390: JAXBUtils.IdentifierType.INTERFACE));
391:
392: Class<?> sei = null;
393: try {
394: sei = Class.forName(seiName.toString(), true, manager
395: .getClass().getClassLoader());
396: } catch (ClassNotFoundException ex) {
397: LOG.log(Level.INFO, "SEI_LOAD_FAILURE_MSG", ex);
398: return null;
399: }
400: Definition def = manager.getDefinition(sei);
401: if (def == null && sei.getInterfaces().length > 0) {
402: sei = sei.getInterfaces()[0];
403: def = manager.getDefinition(sei);
404: }
405: return def;
406: }
407: return null;
408: }
409:
410: private static List<javax.wsdl.extensions.schema.Schema> getSchemas(
411: Definition definition) {
412: Types types = definition.getTypes();
413: List<javax.wsdl.extensions.schema.Schema> schemaList = new ArrayList<javax.wsdl.extensions.schema.Schema>();
414: if (types != null) {
415: for (Object o : types.getExtensibilityElements()) {
416: if (o instanceof javax.wsdl.extensions.schema.Schema) {
417: javax.wsdl.extensions.schema.Schema s = (javax.wsdl.extensions.schema.Schema) o;
418: schemaList.add(s);
419: }
420: }
421: }
422:
423: Map wsdlImports = definition.getImports();
424: for (Object o : wsdlImports.values()) {
425: if (o instanceof List) {
426: for (Object p : (List) o) {
427: if (p instanceof Import) {
428: schemaList.addAll(getSchemas(((Import) p)
429: .getDefinition()));
430: }
431: }
432: }
433: }
434: return schemaList;
435: }
436:
437: public static Schema getSchema(WSDLManager manager,
438: EndpointReferenceType ref) {
439: Definition definition;
440: try {
441: definition = getWSDLDefinition(manager, ref);
442: } catch (javax.wsdl.WSDLException wsdlEx) {
443: return null;
444: }
445: if (definition == null) {
446: return null;
447: }
448: synchronized (schemaMap) {
449: if (schemaMap.containsKey(definition)) {
450: return schemaMap.get(definition);
451: }
452: }
453: Schema schema = schemaMap.get(definition);
454: if (schema == null) {
455: List<javax.wsdl.extensions.schema.Schema> schemas = getSchemas(definition);
456: SchemaFactory factory = SchemaFactory
457: .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
458: List<Source> schemaSources = new ArrayList<Source>();
459: for (javax.wsdl.extensions.schema.Schema s : schemas) {
460: Source source = new DOMSource(s.getElement());
461: if (source != null) {
462: schemaSources.add(source);
463: }
464: }
465: try {
466: schema = factory.newSchema(schemaSources
467: .toArray(new Source[schemaSources.size()]));
468: if (schema != null) {
469: synchronized (schemaMap) {
470: schemaMap.put(definition, schema);
471: }
472: LOG.log(Level.FINE,
473: "Obtained schema from wsdl definition");
474: }
475: } catch (SAXException ex) {
476: // Something not right with the schema from the wsdl.
477: LOG.log(Level.WARNING, "SAXException for newSchema()",
478: ex);
479: }
480: }
481: return schema;
482: }
483:
484: /**
485: * Gets the WSDL port for the provided endpoint reference.
486: * @param manager - the WSDL manager
487: * @param ref - the endpoint reference
488: * @return Port the wsdl port
489: * @throws WSDLException
490: */
491: public static Port getPort(WSDLManager manager,
492: EndpointReferenceType ref) throws WSDLException {
493:
494: Definition def = getWSDLDefinition(manager, ref);
495: if (def == null) {
496: throw new WSDLException(WSDLException.OTHER_ERROR,
497: "unable to find definition for reference");
498: }
499:
500: MetadataType metadata = ref.getMetadata();
501: for (Object obj : metadata.getAny()) {
502:
503: if (obj instanceof JAXBElement) {
504: Object jaxbVal = ((JAXBElement) obj).getValue();
505:
506: if (jaxbVal instanceof ServiceNameType) {
507: Port port = null;
508: ServiceNameType snt = (ServiceNameType) jaxbVal;
509: LOG.log(Level.FINEST, "found service name ", snt
510: .getEndpointName());
511: Service service = def.getService(snt.getValue());
512: if (service == null) {
513: service = (Service) def.getServices().values()
514: .iterator().next();
515: if (service == null) {
516: return null;
517: }
518: }
519: String endpoint = snt.getEndpointName();
520: if ("".equals(endpoint)
521: && service.getPorts().size() == 1) {
522: port = (Port) service.getPorts().values()
523: .iterator().next();
524: } else {
525: port = service.getPort(endpoint);
526: }
527: // FIXME this needs to be looked at service.getPort(endpoint)
528: //should not return null when endpoint is valid
529: if (port == null) {
530: port = (Port) service.getPorts().values()
531: .iterator().next();
532: }
533: return port;
534: }
535: }
536: }
537:
538: if (def.getServices().size() == 1) {
539: Service service = (Service) def.getServices().values()
540: .iterator().next();
541: if (service.getPorts().size() == 1) {
542: return (Port) service.getPorts().values().iterator()
543: .next();
544: }
545: }
546:
547: QName serviceName = getServiceName(ref);
548: if (null != serviceName) {
549: Service service = def.getService(serviceName);
550: if (service == null) {
551: throw new WSDLException(WSDLException.OTHER_ERROR,
552: "Cannot find service for " + serviceName);
553: }
554: if (service.getPorts().size() == 1) {
555: return (Port) service.getPorts().values().iterator()
556: .next();
557: }
558: String str = getPortName(ref);
559: LOG.log(Level.FINE, "getting port " + str
560: + " from service " + service.getQName());
561: Port port = service.getPort(str);
562: if (port == null) {
563: throw new WSDLException(WSDLException.OTHER_ERROR,
564: "unable to find port " + str);
565: }
566: return port;
567: }
568: // TODO : throw exception here
569: return null;
570: }
571:
572: /**
573: * Get the address from the provided endpoint reference.
574: * @param ref - the endpoint reference
575: * @return String the address of the endpoint
576: */
577: public static String getAddress(EndpointReferenceType ref) {
578: AttributedURIType a = ref.getAddress();
579: if (null != a) {
580: return a.getValue();
581: }
582: // should wsdl be parsed for an address now?
583: return null;
584: }
585:
586: /**
587: * Set the address of the provided endpoint reference.
588: * @param ref - the endpoint reference
589: * @param address - the address
590: */
591: public static void setAddress(EndpointReferenceType ref,
592: String address) {
593: AttributedURIType a = new ObjectFactory()
594: .createAttributedURIType();
595: a.setValue(address);
596: ref.setAddress(a);
597: }
598:
599: /**
600: * Create an endpoint reference for the provided wsdl, service and portname.
601: * @param wsdlUrl - url of the wsdl that describes the service.
602: * @param serviceName - the <code>QName</code> of the service.
603: * @param portName - the name of the port.
604: * @return EndpointReferenceType - the endpoint reference
605: */
606: public static EndpointReferenceType getEndpointReference(
607: URL wsdlUrl, QName serviceName, String portName) {
608: EndpointReferenceType reference = new EndpointReferenceType();
609: reference.setMetadata(new MetadataType());
610: setServiceAndPortName(reference, serviceName, portName);
611: //TODO To Ensure it is a valid URI syntax.
612: setWSDLLocation(reference, wsdlUrl.toString());
613:
614: return reference;
615: }
616:
617: /**
618: * Create an endpoint reference for the provided .
619: * @param address - address URI
620: * @return EndpointReferenceType - the endpoint reference
621: */
622: public static EndpointReferenceType getEndpointReference(
623: String address) {
624:
625: EndpointReferenceType reference = new EndpointReferenceType();
626: setAddress(reference, address);
627: return reference;
628: }
629:
630: /**
631: * Get the WebService for the provided class. If the class
632: * itself does not have a WebService annotation, this method
633: * is called recursively on the class's interfaces and superclass.
634: * @param cls - the Class .
635: * @return WebService - the web service
636: */
637: public static WebService getWebServiceAnnotation(Class<?> cls) {
638: if (cls == null) {
639: return null;
640: }
641: WebService ws = cls.getAnnotation(WebService.class);
642: if (null != ws) {
643: return ws;
644: }
645: for (Class<?> inf : cls.getInterfaces()) {
646: ws = getWebServiceAnnotation(inf);
647: if (null != ws) {
648: return ws;
649: }
650: }
651:
652: return getWebServiceAnnotation(cls.getSuperclass());
653: }
654:
655: /**
656: * Gets an endpoint reference for the provided implementor object.
657: * @param manager - the wsdl manager.
658: * @param implementor - the service implementor.
659: * @return EndpointReferenceType - the endpoint reference
660: * @throws WSDLException
661: */
662: public static EndpointReferenceType getEndpointReference(
663: WSDLManager manager, Object implementor) {
664: return getEndpointReference(manager, implementor.getClass());
665: }
666:
667: /**
668: * Gets an endpoint reference for the provided implementor object.
669: * @param manager - the wsdl manager.
670: * @param implementor - the service implementor.
671: * @return EndpointReferenceType - the endpoint reference
672: * @throws WSDLException
673: */
674: public static EndpointReferenceType getEndpointReference(
675: WSDLManager manager, Class<?> implementorClass) {
676:
677: WebService ws = getWebServiceAnnotation(implementorClass);
678:
679: WebServiceProvider wsp = null;
680: if (null == ws) {
681: wsp = implementorClass
682: .getAnnotation(WebServiceProvider.class);
683: if (null == wsp) {
684: return null;
685: }
686: }
687:
688: EndpointReferenceType reference = new EndpointReferenceType();
689: reference.setMetadata(new MetadataType());
690: String serviceName = (null != ws) ? ws.serviceName() : wsp
691: .serviceName();
692: String targetNamespace = (null != ws) ? ws.targetNamespace()
693: : wsp.targetNamespace();
694: String portName = (null != ws) ? ws.portName() : wsp.portName();
695: String url = (null != ws) ? ws.wsdlLocation() : wsp
696: .wsdlLocation();
697: String className = (null != ws) ? ws.endpointInterface() : null;
698:
699: QName portTypeName = null;
700: if (null != className && !"".equals(className)) {
701: Class<?> seiClazz = null;
702: try {
703: seiClazz = Class.forName(className);
704: } catch (ClassNotFoundException cnfe) {
705: LOG.log(Level.SEVERE, "SEI_LOAD_FAILURE_MSG", cnfe);
706: throw new WebServiceException(
707: "endpointInterface element in WebService annotation invalid",
708: cnfe);
709: }
710:
711: if (!seiClazz.isInterface()) {
712: throw new WebServiceException(
713: "endpointInterface element does not refer to a java interface");
714: }
715:
716: WebService seiws = seiClazz.getAnnotation(WebService.class);
717: if (null == seiws) {
718: throw new WebServiceException(
719: "SEI should have a WebService Annotation");
720: }
721:
722: if ("".equals(url)) {
723: url = seiws.wsdlLocation();
724: }
725:
726: //WebService.name maps to wsdl:portType name.
727: portTypeName = new QName(ws.targetNamespace(), seiws.name());
728:
729: //ServiceName,portName,endpointInterface not allowed on the WebService annotation
730: // of a SEI, Section 3.2 JSR181.
731: // set interfaceName using WebService.targetNamespace of SEI only.
732: } else {
733:
734: if (null != ws) {
735: className = ws.name();
736: }
737: if (null == className || "".equals(className)) {
738: className = implementorClass.getSimpleName();
739: }
740: portTypeName = new QName(targetNamespace, className);
741: }
742:
743: setInterfaceName(reference, portTypeName);
744: // set serviceName, portName and targetNamespace
745: if (!"".equals(serviceName)) {
746: setServiceAndPortName(reference, new QName(targetNamespace,
747: serviceName), portName);
748: }
749:
750: if (null != url && url.length() > 0) {
751: //REVISIT Resolve the url for all cases
752: URL wsdlUrl = implementorClass.getResource(url);
753: if (wsdlUrl != null) {
754: url = wsdlUrl.toExternalForm();
755: }
756: }
757: // set wsdlLocation
758: if (!"".equals(url)) {
759: setWSDLLocation(reference, url);
760: }
761:
762: if (LOG.isLoggable(Level.FINE)) {
763: LOG.fine("created endpoint reference with");
764: LOG.fine(" service name: " + getServiceName(reference));
765: LOG
766: .fine(" wsdl location: "
767: + getWSDLLocation(reference));
768: LOG.fine(" sei class: " + getInterfaceName(reference));
769: }
770: return reference;
771: }
772:
773: private static String getNameSpaceUri(Node node, String content,
774: String namespaceURI) {
775: if (namespaceURI == null) {
776: namespaceURI = node.lookupNamespaceURI(content.substring(0,
777: content.indexOf(":")));
778: }
779: return namespaceURI;
780: }
781:
782: private static String getService(String content) {
783: return content.substring(content.indexOf(":") + 1, content
784: .length());
785: }
786: }
|