Java Code Examples for javax.wsdl.BindingOperation#getBindingOutput()

The following examples show how to use javax.wsdl.BindingOperation#getBindingOutput() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setOutputEncodingStyle( SOAPEnvelope soapEnvelope, String operationName )
	throws IOException, SOAPException {
	Port port = getWSDLPort();
	if( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		if( bindingOperation == null ) {
			return;
		}
		BindingOutput output = bindingOperation.getBindingOutput();
		if( output == null ) {
			return;
		}
		for( ExtensibilityElement element : (List< ExtensibilityElement >) output.getExtensibilityElements() ) {
			if( element instanceof javax.wsdl.extensions.soap.SOAPBody ) {
				List< String > list = ((javax.wsdl.extensions.soap.SOAPBody) element).getEncodingStyles();
				if( list != null && list.isEmpty() == false ) {
					soapEnvelope.setEncodingStyle( list.get( 0 ) );
					soapEnvelope.addNamespaceDeclaration( "enc", list.get( 0 ) );
				}
			}
		}
	}
}
 
Example 2
Source File: WsdlUtils.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Build a HashSet of SOAP header names for the specified operation and binding.
 *
 * @param binding       WSDL Binding instance.
 * @param operationName Name of the operation.
 * @return HashSet of soap header names, empty set if no headers present.
 */
protected static HashSet<String> getSOAPHeaders( Binding binding, String operationName ) {

  List<ExtensibilityElement> headers = new ArrayList<ExtensibilityElement>();
  BindingOperation bindingOperation = binding.getBindingOperation( operationName, null, null );
  if ( bindingOperation == null ) {
    throw new IllegalArgumentException( "Can not find operation: " + operationName );
  }

  BindingInput bindingInput = bindingOperation.getBindingInput();
  if ( bindingInput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( (ElementExtensible) bindingInput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  BindingOutput bindingOutput = bindingOperation.getBindingOutput();
  if ( bindingOutput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( (ElementExtensible) bindingOutput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  HashSet<String> headerSet = new HashSet<String>( headers.size() );
  for ( ExtensibilityElement element : headers ) {
    if ( element instanceof SOAP12Header ) {
      headerSet.add( ( (SOAP12Header) element ).getPart() );
    } else {
      headerSet.add( ( (SOAPHeader) element ).getPart() );
    }
  }

  return headerSet;
}
 
Example 3
Source File: WSIBPValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean checkR2209(final Operation operation,
                           final BindingOperation bop) {
    if ((bop.getBindingInput() == null && operation.getInput() != null)
        || (bop.getBindingOutput() == null && operation.getOutput() != null)) {
        addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2209")
                        + "Unbound PortType elements in Operation '" + operation.getName() + "'");
        return false;
    }
    return true;
}
 
Example 4
Source File: WSDLToIDLAction.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void collectIdlDefns(Binding binding) throws Exception {
    boolean isOneway = false;
    Iterator<?> iterator = binding.getBindingOperations().iterator();
    while (iterator.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation)iterator.next();
        if (bindingOperation.getBindingOutput() == null) {
            isOneway = true;
        }

        addOperation(bindingOperation, isOneway);
    }
}
 
Example 5
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SoapBody getBindingOutputSOAPBody(BindingOperation bop) {
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPBody(obj)) {
                return getSoapBody(obj);
            }
        }
    }

    return null;
}
 
Example 6
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SoapHeader getBindingOutputSOAPHeader(BindingOperation bop) {
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                return getProxy(SoapHeader.class, obj);
            }
        }
    }

    return null;
}
 
Example 7
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static List<SoapHeader> getBindingOutputSOAPHeaders(BindingOperation bop) {
    List<SoapHeader> headers = new ArrayList<>();
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                headers.add(getProxy(SoapHeader.class, obj));
            }
        }
    }
    return headers;
}
 
Example 8
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPBody getBindingOutputSOAPBody(BindingOperation bop) {
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPBody(obj)) {
                return getSoapBody(obj);
            }
        }
    }

    return null;
}
 
Example 9
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPHeader getBindingOutputSOAPHeader(BindingOperation bop) {
    BindingOutput bindingOutput = bop.getBindingOutput();
    if (bindingOutput != null) {
        for (Object obj : bindingOutput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                return getProxy(SOAPHeader.class, obj);
            }
        }
    }

    return null;
}
 
Example 10
Source File: WsdlUtils.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Build a HashSet of SOAP header names for the specified operation and binding.
 *
 * @param binding
 *          WSDL Binding instance.
 * @param operationName
 *          Name of the operation.
 * @return HashSet of soap header names, empty set if no headers present.
 */
protected static HashSet<String> getSOAPHeaders( Binding binding, String operationName ) {

  List<ExtensibilityElement> headers = new ArrayList<ExtensibilityElement>();
  BindingOperation bindingOperation = binding.getBindingOperation( operationName, null, null );
  if ( bindingOperation == null ) {
    throw new IllegalArgumentException( "Can not find operation: " + operationName );
  }

  BindingInput bindingInput = bindingOperation.getBindingInput();
  if ( bindingInput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( bindingInput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  BindingOutput bindingOutput = bindingOperation.getBindingOutput();
  if ( bindingOutput != null ) {
    headers.addAll( WsdlUtils.findExtensibilityElements( bindingOutput, SOAP_HEADER_ELEMENT_NAME ) );
  }

  HashSet<String> headerSet = new HashSet<String>( headers.size() );
  for ( ExtensibilityElement element : headers ) {
    if ( element instanceof SOAP12Header ) {
      headerSet.add( ( (SOAP12Header) element ).getPart() );
    } else {
      headerSet.add( ( (SOAPHeader) element ).getPart() );
    }
  }

  return headerSet;
}
 
Example 11
Source File: WSDLRefValidator.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void collectValidationPointsForBindings() throws Exception {
    Map<QName, XNode> vBindingNodes = new HashMap<>();
    for (Service service : services.values()) {
        vBindingNodes.putAll(getBindings(service));
    }

    for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) {
        QName bName = entry.getKey();
        Binding binding = this.definition.getBinding(bName);
        if (binding == null) {
            LOG.log(Level.SEVERE, bName.toString()
                    + " is not correct, please check that the correct namespace is being used");
            throw new Exception(bName.toString()
                    + " is not correct, please check that the correct namespace is being used");
        }
        XNode vBindingNode = getXNode(binding);
        vBindingNode.setFailurePoint(entry.getValue());
        vNodes.add(vBindingNode);

        if (binding.getPortType() == null) {
            continue;
        }
        portTypeRefNames.add(binding.getPortType().getQName());

        XNode vPortTypeNode = getXNode(binding.getPortType());
        vPortTypeNode.setFailurePoint(vBindingNode);
        vNodes.add(vPortTypeNode);
        Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation bop : bops) {
            XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName());
            XNode vBopNode = getOperationXNode(vBindingNode, bop.getName());
            vOpNode.setFailurePoint(vBopNode);
            vNodes.add(vOpNode);
            if (bop.getBindingInput() != null) {
                String inName = bop.getBindingInput().getName();
                if (!StringUtils.isEmpty(inName)) {
                    XNode vInputNode = getInputXNode(vOpNode, inName);
                    vInputNode.setFailurePoint(getInputXNode(vBopNode, inName));
                    vNodes.add(vInputNode);
                }
            }
            if (bop.getBindingOutput() != null) {
                String outName = bop.getBindingOutput().getName();
                if (!StringUtils.isEmpty(outName)) {
                    XNode vOutputNode = getOutputXNode(vOpNode, outName);
                    vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName));
                    vNodes.add(vOutputNode);
                }
            }
            for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext();) {
                String faultName = (String) iter1.next();
                XNode vFaultNode = getFaultXNode(vOpNode, faultName);
                vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName));
                vNodes.add(vFaultNode);
            }
        }
    }
}
 
Example 12
Source File: AbstractWSDLBindingFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected BindingInfo initializeBindingInfo(ServiceInfo service, Binding binding, BindingInfo bi) {
    bi.setName(binding.getQName());
    copyExtensors(bi, binding, null);

    for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
        String inName = null;
        String outName = null;
        if (bop.getBindingInput() != null) {
            inName = bop.getBindingInput().getName();
        }
        if (bop.getBindingOutput() != null) {
            outName = bop.getBindingOutput().getName();
        }
        String portTypeNs = binding.getPortType().getQName().getNamespaceURI();
        QName opName = new QName(portTypeNs,
                                 bop.getName());
        BindingOperationInfo bop2 = bi.getOperation(opName);
        if (bop2 == null) {
            bop2 = bi.buildOperation(opName, inName, outName);
            if (bop2 != null) {
                bi.addOperation(bop2);
            }
        }
        if (bop2 != null) {
            copyExtensors(bop2, bop, bop2);
            if (bop.getBindingInput() != null) {
                copyExtensors(bop2.getInput(), bop.getBindingInput(), bop2);
            }
            if (bop.getBindingOutput() != null) {
                copyExtensors(bop2.getOutput(), bop.getBindingOutput(), bop2);
            }
            for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                if (StringUtils.isEmpty(f.getName())) {
                    throw new IllegalArgumentException("wsdl:fault and soap:fault elements"
                                                       + " must have a name attribute.");
                }
                copyExtensors(bop2.getFault(new QName(service.getTargetNamespace(), f.getName())),
                              bop.getBindingFault(f.getName()), bop2);
            }
        }
    }
    return bi;
}
 
Example 13
Source File: ManagementBusInvocationPluginSoapHttp.java    From container with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if the specified operation of the specified wsdl defines output parameter.
 *
 * @return <code>true</code> if operation returns output params. Otherwise <code>false</code>.
 * If operation can't be found <code>null</code> is returned.
 */
private boolean hasOutputDefined(final BindingOperation operation) {
    // If wsdl is not accessible, try again (max wait 5 min)
    return operation.getBindingOutput() != null;
}