javax.wsdl.Port.setBinding()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中javax.wsdl.Port.setBinding()方法的一些代码示例,展示了Port.setBinding()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Port.setBinding()方法的具体详情如下:
包路径:javax.wsdl.Port
类名称:Port
方法名:setBinding

Port.setBinding介绍

[英]Set the binding this port should refer to.
[中]设置此端口应参考的绑定。

代码示例

代码示例来源:origin: wsdl4j/wsdl4j

port.setBinding(binding);

代码示例来源:origin: org.springframework.ws/spring-ws-core

private void createPorts(Definition definition, Service service) throws WSDLException {
  for (Iterator<?> iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
    Binding binding = (Binding) iterator.next();
    Port port = null;
    for (Iterator<?> iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
      Port existingPort = (Port) iterator1.next();
      if (binding.equals(existingPort.getBinding())) {
        port = existingPort;
      }
    }
    if (port == null) {
      port = definition.createPort();
      port.setBinding(binding);
    }
    populatePort(definition, port);
    if (StringUtils.hasText(port.getName())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Adding port [" + port.getName() + "] to service [" + service.getQName() + "]");
      }
      service.addPort(port);
    }
  }
  if (service.getPorts().isEmpty() && logger.isWarnEnabled()) {
    logger.warn("No ports were created, make sure the WSDL contains bindings");
  }
}

代码示例来源:origin: org.springframework.ws/org.springframework.ws

private void createPorts(Definition definition, Service service) throws WSDLException {
  for (Iterator<?> iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
    Binding binding = (Binding) iterator.next();
    Port port = null;
    for (Iterator<?> iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
      Port existingPort = (Port) iterator1.next();
      if (binding.equals(existingPort.getBinding())) {
        port = existingPort;
      }
    }
    if (port == null) {
      port = definition.createPort();
      port.setBinding(binding);
    }
    populatePort(definition, port);
    if (StringUtils.hasText(port.getName())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Adding port [" + port.getName() + "] to service [" + service.getQName() + "]");
      }
      service.addPort(port);
    }
  }
  if (service.getPorts().isEmpty() && logger.isWarnEnabled()) {
    logger.warn("No ports were created, make sure the WSDL contains bindings");
  }
}

代码示例来源:origin: spring-projects/spring-ws

private void createPorts(Definition definition, Service service) throws WSDLException {
  for (Iterator<?> iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
    Binding binding = (Binding) iterator.next();
    Port port = null;
    for (Iterator<?> iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
      Port existingPort = (Port) iterator1.next();
      if (binding.equals(existingPort.getBinding())) {
        port = existingPort;
      }
    }
    if (port == null) {
      port = definition.createPort();
      port.setBinding(binding);
    }
    populatePort(definition, port);
    if (StringUtils.hasText(port.getName())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Adding port [" + port.getName() + "] to service [" + service.getQName() + "]");
      }
      service.addPort(port);
    }
  }
  if (service.getPorts().isEmpty() && logger.isWarnEnabled()) {
    logger.warn("No ports were created, make sure the WSDL contains bindings");
  }
}

代码示例来源:origin: apache/servicemix-bundles

private void createPorts(Definition definition, Service service) throws WSDLException {
  for (Iterator<?> iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
    Binding binding = (Binding) iterator.next();
    Port port = null;
    for (Iterator<?> iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
      Port existingPort = (Port) iterator1.next();
      if (binding.equals(existingPort.getBinding())) {
        port = existingPort;
      }
    }
    if (port == null) {
      port = definition.createPort();
      port.setBinding(binding);
    }
    populatePort(definition, port);
    if (StringUtils.hasText(port.getName())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Adding port [" + port.getName() + "] to service [" + service.getQName() + "]");
      }
      service.addPort(port);
    }
  }
  if (service.getPorts().isEmpty() && logger.isWarnEnabled()) {
    logger.warn("No ports were created, make sure the WSDL contains bindings");
  }
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

public Port createPort(Endpoint endpoint, WSDLBuilder builder, javax.wsdl.Binding wbinding)
{
  SOAPAddressImpl add = new SOAPAddressImpl();
  add.setLocationURI(endpoint.getUrl());
  
  Port port = builder.getDefinition().createPort();
  port.setBinding( wbinding );
  port.setName( endpoint.getName().getLocalPart() );
  port.addExtensibilityElement( add );
    return port;
}

代码示例来源:origin: apache/cxf

public static javax.wsdl.Service doAppendService(Definition wsdlDefinition,
                         String existPortName, ExtensionRegistry
                         extReg, Binding binding) throws Exception {
  javax.wsdl.Service wsdlService = wsdlDefinition.createService();
  wsdlService.setQName(new QName(wsdlDefinition.getTargetNamespace(), existPortName + serviceName));
  Port port = wsdlDefinition.createPort();
  port.setName(existPortName + portName);
  port.setBinding(binding);
  SOAPAddress address = PartialWSDLProcessor.setAddrElement(wsdlDefinition, port, extReg);
  port.addExtensibilityElement(address);
  wsdlService.addPort(port);
  return wsdlService;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-core

public static javax.wsdl.Service doAppendService(Definition wsdlDefinition, 
                         String existPortName, ExtensionRegistry
                         extReg, Binding binding) throws Exception {
  javax.wsdl.Service wsdlService = wsdlDefinition.createService();
  wsdlService.setQName(new QName(wsdlDefinition.getTargetNamespace(), existPortName + serviceName));
  Port port = wsdlDefinition.createPort();
  port.setName(existPortName + portName);
  port.setBinding(binding);
  SOAPAddress address = PartialWSDLProcessor.setAddrElement(wsdlDefinition, port, extReg);
  port.addExtensibilityElement(address);
  wsdlService.addPort(port);
  return wsdlService;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public static javax.wsdl.Service doAppendService(Definition wsdlDefinition, 
                         String existPortName, ExtensionRegistry
                         extReg, Binding binding) throws Exception {
  javax.wsdl.Service wsdlService = wsdlDefinition.createService();
  wsdlService.setQName(new QName(wsdlDefinition.getTargetNamespace(), existPortName + serviceName));
  Port port = wsdlDefinition.createPort();
  port.setName(existPortName + portName);
  port.setBinding(binding);
  SOAPAddress address = PartialWSDLProcessor.setAddrElement(wsdlDefinition, port, extReg);
  port.addExtensibilityElement(address);
  wsdlService.addPort(port);
  return wsdlService;
}

代码示例来源:origin: apache/cxf

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
}

代码示例来源:origin: org.apache.cxf/cxf-tools-misctools

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
}

代码示例来源:origin: org.objectweb.celtix/celtix-tools

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
}

代码示例来源:origin: org.objectweb.celtix/celtix-tools

public void generate() {
    Service service = definition.createService();
    service.setQName(new QName(WSDLConstants.WSDL_PREFIX, wmodel.getServiceName()));
    Port port = definition.createPort();
    port.setName(wmodel.getPortName());
    Binding binding = definition.createBinding();
    String targetNameSpace = wmodel.getTargetNameSpace();
    binding.setQName(new QName(targetNameSpace, wmodel.getPortTypeName() + "Binding"));
    port.setBinding(binding);
    SOAPAddress soapAddress = null;
    try {
      soapAddress = (SOAPAddress)extensionRegistry
        .createExtension(Port.class, new QName(WSDLConstants.SOAP11_NAMESPACE, "address"));
      soapAddress.setLocationURI(ADDRESS_URI);
    } catch (WSDLException e) {
      throw new ToolException(e.getMessage(), e);
    }
    port.addExtensibilityElement(soapAddress);
    service.addPort(port);
    definition.addService(service);
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

public Port createPort(Definition definition, Binding binding, Service service, String uri) {
  try {
    Port port = definition.createPort();
    port.setBinding(binding);
    configurePort(port, binding);
    if (uri != null) {
      ExtensibilityElement portExtension =
        definition.getExtensionRegistry().createExtension(Port.class, soapAddress);
      if (requiresSOAP12) {
        ((SOAP12Address)portExtension).setLocationURI(uri);
      } else {
        ((SOAPAddress)portExtension).setLocationURI(uri);
      }
      port.addExtensibilityElement(portExtension);
    }
    service.addPort(port);
    return port;
  } catch (WSDLException e) {
    throw new WSDLGenerationException(e);
  }
}

代码示例来源:origin: apache/cxf

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
  WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
  Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
  try {
    wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
  } catch (WSDLException wse) {
    Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
    throw new ToolException(msg, wse);
  }
  try {
    outputWriter.close();
  } catch (IOException ioe) {
    Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
    throw new ToolException(msg, ioe);
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-wsdlgen

public Port createPort(Definition definition, Binding binding, Service service, String uri) {
  try {
    Port port = definition.createPort();
    port.setBinding(binding);
    configurePort(port, binding);
    if (uri != null) {
      ExtensibilityElement portExtension =
        definition.getExtensionRegistry().createExtension(Port.class, soapAddress);
      if (requiresSOAP12) {
        ((SOAP12Address)portExtension).setLocationURI(uri);
      } else {
        ((SOAPAddress)portExtension).setLocationURI(uri);
      }
      port.addExtensibilityElement(portExtension);
    }
    service.addPort(port);
    return port;
  } catch (WSDLException e) {
    throw new WSDLGenerationException(e);
  }
}

代码示例来源:origin: org.objectweb.celtix/celtix-tools

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
  WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
  Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
  try {
    wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
  } catch (WSDLException wse) {
    Message msg = new Message("FAIl_TO_WRITE_WSDL", LOG);
    throw new ToolException(msg, wse);
  }
  try {
    outputWriter.close();
  } catch (IOException ioe) {
    Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
    throw new ToolException(msg, ioe);
  }
}

代码示例来源:origin: org.apache.cxf/cxf-tools-misctools

private void doAppendService() throws ToolException {
  if (service == null) {
    service = wsdlDefinition.createService();
    service
      .setQName(new QName(WSDLConstants.WSDL_PREFIX, (String)env.get(ToolConstants.CFG_SERVICE)));
  }
  if (port == null) {
    port = wsdlDefinition.createPort();
    port.setName((String)env.get(ToolConstants.CFG_PORT));
    port.setBinding(binding);
  }
  setAddrElement();
  service.addPort(port);
  wsdlDefinition.addService(service);
  WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
  Writer outputWriter = getOutputWriter(NEW_FILE_NAME_MODIFIER);
  try {
    wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
  } catch (WSDLException wse) {
    Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
    throw new ToolException(msg, wse);
  }
  try {
    outputWriter.close();
  } catch (IOException ioe) {
    Message msg = new Message("FAIL_TO_CLOSE_WSDL_FILE", LOG);
    throw new ToolException(msg, ioe);
  }
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

public Port createPort(WSDLBuilder builder, javax.wsdl.Binding wbinding)
  {
    Transport t = builder.getTransportManager().getTransport(getBindingId());
    if (!(t instanceof WSDL11Transport)) return null;
    
    WSDL11Transport transport = (WSDL11Transport) t;
    
    SOAPAddressImpl add = new SOAPAddressImpl();
    add.setLocationURI(transport.getServiceURL(builder.getService()));
    
    Port port = builder.getDefinition().createPort();
    port.setBinding( wbinding );
    QName portName = (QName) builder.getService().getProperty(ObjectServiceFactory.PORT_NAME);
    if (portName != null)
    {
      port.setName(portName.getLocalPart());   
    }
    else
    {
      port.setName( builder.getService().getSimpleName() + transport.getName() + "Port" );
    }
    port.addExtensibilityElement( add );
        return port;
  }
}

代码示例来源:origin: org.wso2.wsdl.validator/wsdl-validator

/**
 * Generates a service port given it's name and binding name.
 * The port is then added to the service passed in the constructor.
 * @return the Port instance
 */
public Port generatePort()
{
 String portName = getName();
 String bindingName = getRefName();
 Binding binding = getBinding(bindingName);
 Port port = WSDLFactory.eINSTANCE.createPort();
 port.setName(portName);
 port.setEnclosingDefinition(definition);
 port.setBinding(binding);
 service.addPort(port);
 ContentGenerator contentGenerator = getContentGenerator();
 if (contentGenerator != null)
 {
  //wtp bug 221024 - namespace and prefixes are not added when add new port
  addRequiredNamespaces(service.getEnclosingDefinition());
  contentGenerator.setAddressLocation(addressLocation);
  contentGenerator.generatePortContent(port);
 }
 return port;
}

相关文章