javax.wsdl.extensions.soap.SOAPHeader Java Examples

The following examples show how to use javax.wsdl.extensions.soap.SOAPHeader. 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: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
private List<SOAPHeader> makeHeaders(Definition definition) throws WSDLException {
  List<SOAPHeader> list = new ArrayList<SOAPHeader>();
  String[] parts = new String[] { XTeeHeader.CLIENT.getLocalPart(), XTeeHeader.SERVICE.getLocalPart(),
                                  XTeeHeader.USER_ID.getLocalPart(), XTeeHeader.ID.getLocalPart(),
                                  XTeeHeader.PROTOCOL_VERSION.getLocalPart() };
  ExtensionRegistry extReg = definition.getExtensionRegistry();
  for (int i = 0; i < parts.length; i++) {
    SOAPHeader header =
        (SOAPHeader) extReg.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, "header"));
    header.setMessage(new QName(definition.getTargetNamespace(), XTeeWsdlDefinition.XROAD_HEADER));
    header.setPart(parts[i]);
    if (use.equalsIgnoreCase(LITERAL)) {
      header.setUse(LITERAL);
    } else {
      header.setUse(ENCODED);
      header.setEncodingStyles(Arrays.asList(ENCODING));
    }
    list.add(header);
  }

  return list;
}
 
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: XTeeSoapProvider.java    From j-road with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateBindingInput(Definition definition, BindingInput bindingInput, Input input)
    throws WSDLException {
  for (SOAPHeader header : makeHeaders(definition)) {
    bindingInput.addExtensibilityElement(header);
  }
  super.populateBindingInput(definition, bindingInput, input);
}
 
Example #4
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output)
    throws WSDLException {
  for (SOAPHeader header : makeHeaders(definition)) {
    bindingOutput.addExtensibilityElement(header);
  }
  super.populateBindingOutput(definition, bindingOutput, output);
}
 
Example #5
Source File: UniqueBodyPartsValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean isValid() {
    Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
    for (Binding binding : bindings) {
        uniqueBodyPartsMap = new HashMap<>();
        List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation op : ops) {
            Operation operation = op.getOperation();
            if (operation != null && operation.getInput() != null) {
                Message inMessage = operation.getInput().getMessage();
                BindingInput bin = op.getBindingInput();
                Set<String> headers = new HashSet<>();
                if (bin != null) {
                    List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
                    for (ExtensibilityElement ext : lst) {
                        if (!(ext instanceof SOAPHeader)) {
                            continue;
                        }
                        SOAPHeader header = (SOAPHeader)ext;
                        if (!header.getMessage().equals(inMessage.getQName())) {
                            continue;
                        }
                        headers.add(header.getPart());
                    }
                }

                //find the headers as they don't contribute to the body

                if (inMessage != null && !isUniqueBodyPart(operation.getName(),
                                                           inMessage,
                                                           headers,
                                                           binding.getQName())) {
                    return false;
                }
            }
        }
    }
    return true;
}
 
Example #6
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static List<SOAPHeader> getSoapHeaders(List<ExtensibilityElement> exts) {
    List<SOAPHeader> headers = new ArrayList<>();
    if (exts != null) {
        for (ExtensibilityElement ext : exts) {
            if (isSOAPHeader(ext)) {
                headers.add(getSoapHeader(ext));
            }
        }
    }
    return headers;
}
 
Example #7
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPHeader getBindingInputSOAPHeader(BindingOperation bop) {
    BindingInput bindingInput = bop.getBindingInput();
    if (bindingInput != null) {
        for (Object obj : bindingInput.getExtensibilityElements()) {
            if (isSOAPHeader(obj)) {
                return getProxy(SOAPHeader.class, obj);
            }
        }
    }

    return null;
}
 
Example #8
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 #9
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPHeader createSoapHeader(ExtensionRegistry extReg, Class<?> clz, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(clz,
                                                          new QName(WSDLConstants.NS_SOAP12,
                                                                    "header"));
    } else {
        extElement = extReg.createExtension(clz,
                                                        new QName(WSDLConstants.NS_SOAP11,
                                                                  "header"));
    }
    return getSoapHeader(extElement);
}
 
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: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static boolean isSOAPHeader(Object obj) {
    return obj instanceof SOAPHeader || obj instanceof SOAP12Header;
}
 
Example #12
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static boolean isSOAPHeader(Object obj) {
    return obj instanceof SOAPHeader || obj instanceof SOAP12Header;
}
 
Example #13
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static SOAPHeader getSoapHeader(Object obj) {
    if (isSOAPHeader(obj)) {
        return getProxy(SOAPHeader.class, obj);
    }
    return null;
}