Esempio n. 1
0
  private joliex.wsdl.impl.Operation convertOperation(Operation operation, Style style)
      throws IOException {
    String comment = "";
    if (operation.getDocumentationElement() != null) {
      operation.getDocumentationElement().getNodeValue();
    }
    String responseTypeName = null;

    String requestTypeName =
        convertOperationMessage(operation.getInput().getMessage(), operation.getName(), style);
    if (operation.getOutput() != null) {
      responseTypeName =
          convertOperationMessage(operation.getOutput().getMessage(), operation.getName(), style);
    }

    Map<String, Part> parts;
    List<Pair<String, String>> faultList = new ArrayList<Pair<String, String>>();
    Map<String, Fault> faults = operation.getFaults();
    for (Entry<String, Fault> entry : faults.entrySet()) {
      String faultName = entry.getKey();
      String faultTypeName = null;
      parts = entry.getValue().getMessage().getParts();
      if (parts.size() > 1) {
        String typeName = faultName = faultTypeName;
        TypeInlineDefinition faultType =
            new TypeInlineDefinition(
                URIParsingContext.DEFAULT,
                typeName,
                NativeType.VOID,
                jolie.lang.Constants.RANGE_ONE_TO_ONE);
        for (Entry<String, Part> partEntry : parts.entrySet()) {
          Part part = partEntry.getValue();
          if (part.getElementName() == null) {
            if (part.getTypeName() == null) {
              throw new IOException(
                  "Could not parse message part "
                      + entry.getKey()
                      + " for operation "
                      + operation.getName()
                      + ".");
            }
            TypeDefinitionLink link =
                new TypeDefinitionLink(
                    URIParsingContext.DEFAULT,
                    part.getName(),
                    jolie.lang.Constants.RANGE_ONE_TO_ONE,
                    XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id());
            faultType.putSubType(link);
          } else {
            TypeDefinitionLink link =
                new TypeDefinitionLink(
                    URIParsingContext.DEFAULT,
                    part.getName(),
                    jolie.lang.Constants.RANGE_ONE_TO_ONE,
                    part.getElementName().getLocalPart());
            faultType.putSubType(link);
          }
        }
        typeDefinitions.add(faultType);
      } else {
        for (Entry<String, Part> e : parts.entrySet()) {
          Part part = e.getValue();
          if (part.getElementName() == null) {
            if (part.getTypeName() == null) {
              throw new IOException(
                  "Could not parse message part "
                      + e.getKey()
                      + " for operation "
                      + operation.getName()
                      + ", fault "
                      + entry.getKey()
                      + ".");
            }
            faultTypeName = XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id();
          } else {
            faultTypeName = part.getElementName().getLocalPart();
            NativeType nativeType = XsdUtils.xsdToNativeType(faultTypeName);
            if (nativeType != null) {
              faultTypeName = nativeType.id();
            }
          }
        }
      }
      faultList.add(new Pair<String, String>(faultName, faultTypeName));
    }

    return new joliex.wsdl.impl.Operation(
        operation.getName(), requestTypeName, responseTypeName, faultList, comment);
  }
Esempio n. 2
0
  private String convertOperationMessage(Message message, String operationName, Style style)
      throws IOException {
    String typeName = null; // "void" datatype per default
    Map<String, Part> parts = message.getParts();
    if (parts.size() > 1 || style == Style.RPC) {
      typeName = message.getQName().getLocalPart();
      TypeInlineDefinition requestType =
          new TypeInlineDefinition(
              URIParsingContext.DEFAULT,
              typeName,
              NativeType.VOID,
              jolie.lang.Constants.RANGE_ONE_TO_ONE);
      for (Entry<String, Part> entry : parts.entrySet()) {
        Part part = entry.getValue();
        if (part.getElementName() == null) {
          if (part.getTypeName() == null) {
            throw new IOException(
                "Could not parse message part "
                    + entry.getKey()
                    + " for operation "
                    + operationName
                    + ".");
          }
          TypeDefinitionLink link =
              new TypeDefinitionLink(
                  URIParsingContext.DEFAULT,
                  part.getName(),
                  jolie.lang.Constants.RANGE_ONE_TO_ONE,
                  XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id());
          requestType.putSubType(link);
        } else {
          TypeDefinitionLink link =
              new TypeDefinitionLink(
                  URIParsingContext.DEFAULT,
                  part.getName(),
                  jolie.lang.Constants.RANGE_ONE_TO_ONE,
                  part.getElementName().getLocalPart());
          requestType.putSubType(link);
        }
      }
      typeDefinitions.add(requestType);
    } else {
      for (Entry<String, Part> entry : parts.entrySet()) {
        Part part = entry.getValue();
        if (part.getElementName() == null) {
          if (part.getTypeName() == null) {
            throw new IOException(
                "Could not parse message part "
                    + entry.getKey()
                    + " for operation "
                    + operationName
                    + ".");
          }
          typeName = XsdUtils.xsdToNativeType(part.getTypeName().getLocalPart()).id();
        } else {
          typeName = part.getElementName().getLocalPart();
          NativeType nativeType = XsdUtils.xsdToNativeType(typeName);
          if (nativeType != null) {
            typeName = nativeType.id();
          }
        }
      }
    }

    return typeName;
  }