List of usage examples for javax.xml.ws Service getPorts
public Iterator<javax.xml.namespace.QName> getPorts()
From source file:io.hummer.util.ws.WebServiceClient.java
public static Port getDefaultWSDLPort(javax.wsdl.Service service) { Port soap11 = null;//from w ww. j a v a 2 s. c o m Port soap12 = null; Port http = null; for (Object o : service.getPorts().values()) { Port p = (Port) o; for (Object e : p.getBinding().getExtensibilityElements()) { if (e instanceof SOAP12Binding) { soap12 = p; } else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) { soap11 = p; } else if (e instanceof HTTPBinding) { http = p; } else { logger.warn("Unexpected binding class: " + e + " : " + e.getClass()); } } } if (soap12 != null) return soap12; if (soap11 != null) return soap11; if (http != null) return http; if (service.getPorts().size() <= 0) throw new RuntimeException( "Tried to guess the port name from WSDL, but no suitable port name was found."); return (Port) service.getPorts().values().iterator().next(); }
From source file:org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.java
private void buildEndpointDescriptionFromWSDL() { Definition wsdlDefinition = getServiceDescriptionImpl().getWSDLWrapper().getDefinition(); javax.wsdl.Service wsdlService = wsdlDefinition.getService(getServiceDescription().getServiceQName()); if (wsdlService == null) { throw ExceptionFactory .makeWebServiceException(Messages.getMessage("serviceDescErr2", createAxisServiceName())); }/* www .j ava2 s .c o m*/ Map wsdlPorts = wsdlService.getPorts(); boolean wsdlPortFound = false; if (wsdlPorts != null && wsdlPorts.size() > 0) { Iterator wsdlPortIterator = wsdlPorts.values().iterator(); while (wsdlPortIterator.hasNext() && !wsdlPortFound) { Port wsdlPort = (Port) wsdlPortIterator.next(); // Note the namespace is not included on the WSDL Port. if (wsdlPort.getName().equals(portQName.getLocalPart())) { // Build the EndpointInterface based on the specified SEI if there is one // or on the service impl class (i.e. an implicit SEI). if (composite.isServiceProvider()) { String seiClassName = getAnnoWebServiceEndpointInterface(); if (DescriptionUtils.isEmpty(seiClassName)) { // No SEI specified, so use the service impl as an implicit SEI endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, true, this); } else { // Otherwise, build the EID based on the SEI composite endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl( getServiceDescriptionImpl().getDBCMap().get(seiClassName), false, this); // after this is constructed, we need to update the @WebService.name // attribute on the axisService instance if (axisService != null) { updateWebServiceNameParameter( ((EndpointInterfaceDescriptionImpl) endpointInterfaceDescription) .getAnnoWebServiceName(), axisService); } } } else { // Create the Endpoint Interface Description based on the WSDL. endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(this); // Update the EndpointInterfaceDescription created with WSDL with information from the // annotations in the SEI ((EndpointInterfaceDescriptionImpl) endpointInterfaceDescription) .updateWithSEI(composite.getCorrespondingClass()); } wsdlPortFound = true; } } } if (!wsdlPortFound) { throw ExceptionFactory .makeWebServiceException(Messages.getMessage("serviceDescErr3", portQName.getLocalPart())); } }