javax.wsdl.Binding类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(154)

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

Binding介绍

[英]This interface represents a port type binding and describes the protocol required for using operations in a port type.
[中]此接口表示端口类型绑定,并描述在端口类型中使用操作所需的协议。

代码示例

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

if (!binding.isUndefined())
 QName name = binding.getQName();
              name.getLocalPart(),
              pw);
 PortType portType = binding.getPortType();
                   portType.getQName(),
                   def,
                   pw);
 printDocumentation(binding.getDocumentationElement(), def, pw);
 List extElements = binding.getExtensibilityElements();
 printBindingOperations(binding.getBindingOperations(), def, pw);

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

QName bindingName = new QName(def.getTargetNamespace(), name);
 binding = def.getBinding(bindingName);
  binding = def.createBinding();
  binding.setQName(bindingName);
binding.setUndefined(false);
  portType = def.createPortType();
  portType.setQName(portTypeName);
  def.addPortType(portType);
 binding.setPortType(portType);
  binding.setDocumentationElement(tempEl);
  binding.addBindingOperation(parseBindingOperation(tempEl,
                           portType,
                           def));
  binding.addExtensibilityElement(parseExtensibilityElement(
   Binding.class, tempEl, def));

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

protected void configureBinding(Definition definition, Binding binding, PortType portType) throws WSDLException {
  if ( wsBindingName != null ) {
    QName name = new QName(definition.getTargetNamespace(), wsBindingName + getSOAPVersionString() + BINDING_SUFFIX);
    if ( definition.getBinding(name) == null ) {
      binding.setQName(name);
      return;
    }
  }
  
  QName portTypeName = portType.getQName();
  if (portTypeName != null) {
    // Choose <porttype>Binding if available.  If this name is in use, insert
    // separating underscores until there is no clash.
    for (String suffix = BINDING_SUFFIX; ; suffix = "_" + suffix) { 
      QName name = new QName(definition.getTargetNamespace(), portTypeName.getLocalPart() + suffix);
      if (definition.getBinding(name) == null) {
        binding.setQName(name);
        break;
      }
    }
  }
}

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

public static Binding doAppendBinding(Definition wsdlDefinition, String name, PortType portType,
                     ExtensionRegistry extReg) throws Exception {
  Binding binding = wsdlDefinition.createBinding();
  binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), name + bindingName));
  binding.setUndefined(false);
  binding.setPortType(portType);
  setSoapBindingExtElement(wsdlDefinition, binding, extReg);
  addBindingOperation(wsdlDefinition, portType, binding, extReg);
  return binding;
}

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

private Map<QName, XNode> getBindings(Service service) {
  Map<QName, XNode> bindings = new HashMap<>();
  if (service.getPorts().values().isEmpty()) {
    throw new ToolException("Service " + service.getQName() + " does not contain any usable ports");
  }
  Collection<Port> ports = CastUtils.cast(service.getPorts().values());
  for (Port port : ports) {
    Binding binding = port.getBinding();
    bindings.put(binding.getQName(), getXNode(service, port));
    if (WSDLConstants.NS_WSDL11.equals(binding.getQName().getNamespaceURI())) {
      throw new ToolException("Binding "
                  + binding.getQName().getLocalPart()
                  + " namespace set improperly.");
    }
  }
  return bindings;
}

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

protected void buildBinding(Definition definition,
              Collection<BindingInfo> bindingInfos,
              Collection<PortType> portTypes) {
  Binding binding = null;
  for (BindingInfo bindingInfo : bindingInfos) {
    binding = definition.createBinding();
    addDocumentation(binding, bindingInfo.getDocumentation());
    binding.setUndefined(false);
    for (PortType portType : portTypes) {
      if (portType.getQName().equals(bindingInfo.getInterface().getName())) {
        binding.setPortType(portType);
        break;
      }
    }
    binding.setQName(bindingInfo.getName());
    if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace())) {
      addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
    }
    buildBindingOperation(definition, binding, bindingInfo.getOperations());
    addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
    definition.addBinding(binding);
  }
}

代码示例来源:origin: org.apache.airavata/airavata-gfac-schema-utils

private Binding addBinding(Definition def, String nameSpaceURI, PortTypeImpl portType,
    UnknownExtensibilityElement wsPolicyRef, DOMImplementation dImpl) {
  String portName = portType.getQName().getLocalPart();
  Binding binding = def.createBinding();
  binding.setQName(new QName(nameSpaceURI, portName + WSDL_SOAP_BINDING_SUFFIX));
  binding.setUndefined(false);
  binding.setPortType(portType);
  SOAPBindingImpl soapBindingImpl = new SOAPBindingImpl();
  soapBindingImpl.setStyle(DOCUMENT);
  soapBindingImpl.setTransportURI(SOAP_HTTP_NAMESPACE);
  binding.addExtensibilityElement(soapBindingImpl);
  if (wsPolicyRef != null) {
    log.debug("policy info is not null");
    binding.addExtensibilityElement(wsPolicyRef);
  }
  Document doc = dImpl.createDocument(WSP_NAMESPACE, "Misc", null);
  UnknownExtensibilityElement exEle = new UnknownExtensibilityElement();
  exEle.setElement(doc.createElementNS("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:UsingAddressing"));
  exEle.setElementType(new QName("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:UsingAddressing"));
  binding.addExtensibilityElement(exEle);
  return binding;
}

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

try {
  Definition def = wsdlManager.getDefinition(wsdlDocumentLocation);
  interfaceName = def.getService(serviceName).getPort(portName.getLocalPart()).getBinding()
    .getPortType().getQName();
} catch (Exception e) {
        ? serviceName.getNamespaceURI() + " " + wsdlDocumentLocation
        : wsdlDocumentLocation;
    writer.writeNamespace(JAXWSAConstants.WSDLI_PFX,
                 JAXWSAConstants.WSAM_INTERFACE_NAME,
                 JAXWSAConstants.NS_WSAM);
    String portTypePrefix = interfaceName.getPrefix();
    if (portTypePrefix == null || portTypePrefix.isEmpty()) {
      portTypePrefix = "ns1";

代码示例来源:origin: org.apache.axis2/axis2-metadata

public String getPortBinding(QName serviceQname, QName portQname) {
  Port port = getPort(serviceQname, portQname);
  if (port == null) {
    return null;
  }
  Binding binding = port.getBinding();
  return binding.getQName().getLocalPart();
}

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

protected void buildBindingOperation(Definition def, Binding binding,
                  Collection<BindingOperationInfo> bindingOperationInfos) {
  BindingOperation bindingOperation = null;
  for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
    bindingOperation = def.createBindingOperation();
    addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
    bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
    for (Operation operation
        : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
      if (operation.getName().equals(bindingOperation.getName())) {
        bindingOperation.setOperation(operation);
        break;
      }
    }
    buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
    buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
    buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
    addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
    addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
    binding.addBindingOperation(bindingOperation);
  }
}

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

private void initializePorts() {
  try {
    Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
    javax.wsdl.Service serv = def.getService(serviceName);
    if (serv == null) {
      throw new WebServiceException("Could not find service named " + serviceName
    Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
    for (Port port : wsdlports.values()) {
      QName name = new QName(serviceName.getNamespaceURI(), port.getName());
        = CastUtils.cast(port.getBinding().getExtensibilityElements());
      if (!extensions.isEmpty()) {
        ExtensibilityElement e = extensions.get(0);
      extensions = CastUtils.cast(port.getExtensibilityElements());
      if (!extensions.isEmpty()) {
        ExtensibilityElement e = extensions.get(0);

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

private XNode getXNode(Binding binding) {
  XDef xdef = new XDef();
  xdef.setTargetNamespace(binding.getQName().getNamespaceURI());
  XBinding bNode = new XBinding();
  bNode.setName(binding.getQName().getLocalPart());
  bNode.setParentNode(xdef);
  return bNode;
}

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

protected void configurePort(Port port, Binding binding) throws WSDLException {
  if ( wsBindingName != null ) {
    port.setName(wsBindingName + getSOAPVersionString() + PORT_SUFFIX);
  } else if (binding.getPortType() != null && binding.getPortType().getQName() != null) {
    port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX);
  }
}

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

private boolean queryBinding(QName bqname) {
  Collection<Binding> bindings = CastUtils.cast(definition.getBindings().values());
  for (Binding binding : bindings) {
    if (binding.getQName().getLocalPart().equals(bqname.getLocalPart())) {
      return true;
    }
  }
  return false;
}

代码示例来源: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.mule.modules/mule-module-cxf

private QName getPortMatchingSoapVersion(Service service)
{
  if (soapVersion == null)
  {
    // No SOAP version specified in the config.
    return null;
  }
  for (Port port : (Iterable<Port>) service.getPorts().values())
  {
    for (Object element : port.getBinding().getExtensibilityElements())
    {
      if ((element instanceof SOAPBinding && "1.1".equals(soapVersion)) ||
        (element instanceof SOAP12Binding && "1.2".equals(soapVersion)))
      {
        return new QName(getServiceNamespace(), port.getName());
      }
    }
  }
  // No port matching the specified SOAP version.
  return null;
}

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

public void generate() {
  Binding binding = definition.createBinding();
  binding.setQName(new QName(WSDLConstants.NS_WSDL, wmodel.getPortTypeName() + "Binding"));
  binding.setPortType(definition.getPortType(new QName(wmodel.getTargetNameSpace(), wmodel
    .getPortTypeName())));
  // genearte the soap binding
  javax.wsdl.extensions.soap.SOAPBinding soapBinding;
  try {
    soapBinding = (javax.wsdl.extensions.soap.SOAPBinding)extensionRegistry
      .createExtension(Binding.class, new QName(WSDLConstants.SOAP11_NAMESPACE, "binding"));
    soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    soapBinding.setStyle(wmodel.getStyle().toString().toLowerCase());
    binding.addExtensibilityElement(soapBinding);
  } catch (WSDLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  generateBindingOperation(binding);
  binding.setUndefined(false);
  definition.addBinding(binding);
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.ws.axis.consumption.ui

/**
* Returns the name of the port type element points to by the first service and port element in the WSDL definition.
* @return String port type element name
*/
public static String getPortTypeName(Definition definition) {
  Service service = (Service) definition.getServices().values().iterator().next();
 Iterator iterator = service.getPorts().values().iterator(); 
 while(iterator.hasNext()){
  Port port = (Port) iterator.next();
  for (int i=0; i<port.getExtensibilityElements().size();i++) {
   if (port.getExtensibilityElements().get(i) instanceof SOAPAddress) {
     Binding binding = port.getBinding();
     return binding.getPortType().getQName().getLocalPart();
   }
  }
 }
 return "";

}

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

private void processPort(Definition srcWsdl, WSDLService destService, Port srcPort) throws WSDLException
{
 log.trace("processPort: " + srcPort.getName());
 Binding srcBinding = getDefinedBinding(srcPort);
 QName endpointName = new QName(srcWsdl.getTargetNamespace(), srcPort.getName());
 WSDLEndpoint destEndpoint = new WSDLEndpoint(destService, endpointName);
 destEndpoint.setBinding(srcBinding.getQName());
 destEndpoint.setAddress(getSOAPAddress(srcPort));
 processUnknownExtensibilityElements(srcPort, destEndpoint);
 WSDLBinding destBinding = processBinding(srcWsdl, srcBinding);
 if (destBinding != null)
   destService.addEndpoint(destEndpoint);
}

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

private boolean validateService() {
  Map serviceMap = def.getServices();
  Iterator ite = serviceMap.values().iterator();
  while (ite.hasNext()) {
    Service service = (Service)ite.next();
    Iterator portIte = service.getPorts().values().iterator();
    while (portIte.hasNext()) {
      Port port = (Port)portIte.next();
      Binding binding = port.getBinding();
      if (!bindingMap.containsKey(binding.getQName())) {
        Node errNode = ErrNodeLocator.getNode(document, WSDLConstants.QNAME_SERVICE, service
          .getQName().getLocalPart(), port.getName());
        schemaWSDLValidator.addError(errNode, " port : " + port.getName()
                           + " reference binding is not defined");
        isValid = false;
      }
    }
  }
  return isValid;
}

相关文章