Exemplo n.º 1
0
  protected String addOperationNode(
      NSStack nsStack,
      Message message,
      XMLStreamWriter xmlWriter,
      boolean output,
      BindingOperationInfo boi)
      throws XMLStreamException {
    String responseSuffix = output ? "Response" : "";
    String ns = boi.getName().getNamespaceURI();
    SoapBody body = null;
    if (output) {
      body = boi.getOutput().getExtensor(SoapBody.class);
    } else {
      body = boi.getInput().getExtensor(SoapBody.class);
    }
    if (body != null && !StringUtils.isEmpty(body.getNamespaceURI())) {
      ns = body.getNamespaceURI();
    }

    nsStack.add(ns);
    String prefix = nsStack.getPrefix(ns);
    StaxUtils.writeStartElement(
        xmlWriter, prefix, boi.getName().getLocalPart() + responseSuffix, ns);
    return ns;
  }
Exemplo n.º 2
0
  public void handleMessage(Message message) {
    try {
      NSStack nsStack = new NSStack();
      nsStack.push();

      BindingOperationInfo operation =
          (BindingOperationInfo) message.getExchange().get(BindingOperationInfo.class.getName());

      assert operation.getName() != null;

      XMLStreamWriter xmlWriter = getXMLStreamWriter(message);

      List<MessagePartInfo> parts = null;

      if (!isRequestor(message)) {
        parts = operation.getOutput().getMessageParts();
        addOperationNode(nsStack, message, xmlWriter, true, operation);
      } else {
        parts = operation.getInput().getMessageParts();
        addOperationNode(nsStack, message, xmlWriter, false, operation);
      }

      MessageContentsList objs = MessageContentsList.getContentsList(message);
      if (objs == null) {
        return;
      }

      for (MessagePartInfo part : parts) {
        if (objs.hasValue(part)) {
          Object o = objs.get(part);
          if (o == null) {
            // WSI-BP R2211 - RPC/Lit parts are not allowed to be xsi:nil
            throw new Fault(
                new org.apache.cxf.common.i18n.Message(
                    "BP_2211_RPCLIT_CANNOT_BE_NULL", LOG, part.getConcreteName()));
          }
          // WSI-BP R2737  -RPC/LIG part name space is empty
          // part.setConcreteName(new QName("", part.getConcreteName().getLocalPart()));
        }
      }
      writeParts(message, message.getExchange(), operation, objs, parts);

      // Finishing the writing.
      xmlWriter.writeEndElement();
    } catch (XMLStreamException e) {
      throw new Fault(e);
    }
  }