Java Code Examples for javax.wsdl.Fault#getMessage()

The following examples show how to use javax.wsdl.Fault#getMessage() . 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: WsdlOpFaultList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws HopTransformException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example 2
Source File: OperationInfo.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
public OperationInfo(Operation operation) {
    targetMethodName = operation.getName();

    Input inDef = operation.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            input = getParameterFromMessage(inMsg);
        }
    }
    Output outDef = operation.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            output = getParameterFromMessage(outMsg);
        }
    }
    for (Fault fault : (Collection<Fault>) operation.getFaults().values()) {
        Message faultMsg = fault.getMessage();
        if (faultMsg != null) {
            faults.add(getParameterFromMessage(faultMsg));
        }
    }
}
 
Example 3
Source File: WsdlOpFaultList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault
 *          Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws KettleStepException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example 4
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Collection<String> getAllPaths() throws URISyntaxException {
    final Set<String> paths = new HashSet<String>();
    final Set<QName> portTypes = new HashSet<QName>();
    final Set<QName> alreadyCreated = new HashSet<QName>();
    for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
        final QName portType = binding.getPortType().getQName();
        if (portTypes.add(portType)) {
            for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
                Operation oper = operation.getOperation();
                Input inDef = oper.getInput();
                if (inDef != null) {
                    Message inMsg = inDef.getMessage();
                    addParamsToPath(portType, oper, inMsg, paths, alreadyCreated);
                }

                Output outDef = oper.getOutput();
                if (outDef != null) {
                    Message outMsg = outDef.getMessage();
                    addParamsToPath(portType, oper, outMsg, paths, alreadyCreated);
                }
                for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                    Message faultMsg = fault.getMessage();
                    addParamsToPath(portType, oper, faultMsg, paths, alreadyCreated);
                }
            }
        }
    }
    return paths;
}
 
Example 5
Source File: WSIBPValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean checkR2205() {
    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {

        if (!SOAPBindingUtil.isSOAPBinding(binding)) {
            System.err.println("WSIBP Validator found <"
                               + binding.getQName() + "> is NOT a SOAP binding");
            continue;
        }
        if (binding.getPortType() == null) {
            //will error later
            continue;
        }

        for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext();) {
            Operation operation = (Operation)ite2.next();
            Collection<Fault> faults = CastUtils.cast(operation.getFaults().values());
            if (CollectionUtils.isEmpty(faults)) {
                continue;
            }

            for (Fault fault : faults) {
                Message message = fault.getMessage();
                Collection<Part> parts = CastUtils.cast(message.getParts().values());
                for (Part part : parts) {
                    if (part.getElementName() == null) {
                        addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message "
                            + message.getQName() + ", part " + part.getName()
                                + " must specify a 'element' attribute");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
 
Example 6
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testPingMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation pingMe = portType.getOperation("pingMe", "pingMeRequest", "pingMeResponse");
    assertNotNull(pingMe);
    assertEquals("pingMe", pingMe.getName());
    Input input = pingMe.getInput();
    assertNotNull(input);
    assertEquals("pingMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("pingMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = pingMe.getOutput();
    assertNotNull(output);
    assertEquals("pingMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("pingMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(message.getParts().size(), 1);
    assertEquals("out", message.getPart("out").getName());
    assertEquals(1, pingMe.getFaults().size());
    Fault fault = pingMe.getFault("pingMeFault");
    assertNotNull(fault);
    assertEquals("pingMeFault", fault.getName());
    message = fault.getMessage();
    assertNotNull(message);
    assertEquals("pingMeFault", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("faultDetail", message.getPart("faultDetail").getName());
    assertNull(message.getPart("faultDetail").getTypeName());
}
 
Example 7
Source File: WSDLRefValidator.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void collectValidationPointsForPortTypes() {
    for (QName ptName : portTypeRefNames) {
        PortType portType = getPortType(ptName);
        if (portType == null) {
            vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
            continue;
        }

        XNode vPortTypeNode = getXNode(portType);
        for (Operation operation : getOperations(portType).values()) {
            XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
            if (operation.getInput() == null) {
                vResults.addError(new Message("WRONG_MEP", LOG, operation.getName(),
                                              portType.getQName()));
                continue;
            }
            javax.wsdl.Message inMsg = operation.getInput().getMessage();
            if (inMsg == null) {
                addWarning("Operation " + operation.getName() + " in PortType: "
                           + portType.getQName() + " has no input message");
            } else {
                XNode vInMsgNode = getXNode(inMsg);
                vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
                vNodes.add(vInMsgNode);
                messageRefNames.add(inMsg.getQName());
            }

            if (operation.getOutput() != null) {
                javax.wsdl.Message outMsg = operation.getOutput().getMessage();

                if (outMsg == null) {
                    addWarning("Operation " + operation.getName() + " in PortType: "
                               + portType.getQName() + " has no output message");
                } else {
                    XNode vOutMsgNode = getXNode(outMsg);
                    vOutMsgNode.setFailurePoint(getOutputXNode(vOperationNode,
                                                               operation.getOutput().getName()));
                    vNodes.add(vOutMsgNode);
                    messageRefNames.add(outMsg.getQName());
                }
            }
            for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext();) {
                Fault fault = (Fault) iter.next();
                javax.wsdl.Message faultMsg = fault.getMessage();
                XNode vFaultMsgNode = getXNode(faultMsg);
                vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
                vNodes.add(vFaultMsgNode);
                messageRefNames.add(faultMsg.getQName());
            }
        }
    }
}