private static void testDetailEntry(SOAPElement detailEntry) {
    SOAPElement code = SoapUtil.getElement(detailEntry, "code");
    assertEquals("100", DatatypeUtil.toString(code));

    SOAPElement description = SoapUtil.getElement(detailEntry, "description");
    assertEquals("unknown problem", DatatypeUtil.toString(description));
  }
  public void testWriteFault_dom() throws Exception {
    SOAPMessage soapMessage = writeFault();

    Element envelope = writeAndRead(soapMessage);
    Element body = XmlUtil.getElement(envelope, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Body");
    Element fault = XmlUtil.getElement(body, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Fault");

    Element faultcode = XmlUtil.getElement(fault, "faultcode");
    assertEquals(
        XmlUtil.getPrefix(SoapBindConstants.CLIENT_FAULTCODE.getNamespaceURI(), faultcode)
            + ':'
            + SoapBindConstants.CLIENT_FAULTCODE.getLocalPart(),
        DatatypeUtil.toString(faultcode));

    Element faultstring = XmlUtil.getElement(fault, "faultstring");
    assertEquals(SoapBindConstants.BUSINESS_FAULTSTRING, DatatypeUtil.toString(faultstring));

    Element detail = XmlUtil.getElement(fault, "detail");
    Element faultElement = XmlUtil.getElement(detail, BpelConstants.NS_EXAMPLES, "faultElement");

    Element code = XmlUtil.getElement(faultElement, "code");
    assertEquals("100", DatatypeUtil.toString(code));

    Element description = XmlUtil.getElement(faultElement, "description");
    assertEquals("unknown problem", DatatypeUtil.toString(description));
  }
  public void testWriteOutput_dom_rpc() throws Exception {
    SOAPMessage soapMessage = writeRpcOutput();

    Element envelopeElem = writeAndRead(soapMessage);
    // soap body
    Element bodyElem = XmlUtil.getElement(envelopeElem, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Body");
    // operation wrapper
    Element operationElem = XmlUtil.getElement(bodyElem, BpelConstants.NS_EXAMPLES, "opResponse");

    // simple part
    Element intPart = XmlUtil.getElement(operationElem, "intPart");
    // value
    assertEquals("2020", DatatypeUtil.toString(intPart));

    // complex part
    Element complexPart = XmlUtil.getElement(operationElem, "complexPart");
    // attributes
    assertEquals("hi", complexPart.getAttribute("attributeOne"));
    assertEquals("ho", complexPart.getAttribute("attributeTwo"));
    // child elements
    Element one = XmlUtil.getElement(complexPart, "urn:uriOne", "elementOne");
    assertEquals("ram", DatatypeUtil.toString(one));
    Element two = XmlUtil.getElement(complexPart, "urn:uriTwo", "elementTwo");
    assertEquals("ones", DatatypeUtil.toString(two));
  }
  public void testSendRequest_rpc_nil() throws Exception {
    String requestText =
        "<env:Envelope xmlns:env='"
            + SOAPConstants.URI_NS_SOAP_ENVELOPE
            + "'>"
            + "<env:Body>"
            + "<tns:op xmlns:tns='"
            + BpelConstants.NS_EXAMPLES
            + "' xmlns:xsi='"
            + BpelConstants.NS_XML_SCHEMA_INSTANCE
            + "'>"
            + "  <simplePart xsi:nil='true'>wazabi</simplePart>"
            + "  <complexPart xsi:nil='1'>"
            + "    <b on='true'>true</b>"
            + "    <c name='venus'/>"
            + "    <d amount='20'/>"
            + "    <e>30</e>"
            + "  </complexPart>"
            + "</tns:op>"
            + "</env:Body>"
            + "</env:Envelope>";

    SOAPMessage soapMessage =
        MessageFactory.newInstance()
            .createMessage(null, new ByteArrayInputStream(requestText.getBytes()));

    Connection connection = integrationControl.getJmsConnection();
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    try {
      SoapHandler soapHandler = createRpcHandler();
      soapHandler.sendRequest(soapMessage, session, jbpmContext);

      PartnerLinkEntry entry =
          integrationControl.getPartnerLinkEntry(Q_RPC_PORT_TYPE, Q_SERVICE, RPC_PORT);
      MessageConsumer consumer = session.createConsumer(entry.getDestination());
      ObjectMessage message = (ObjectMessage) consumer.receiveNoWait();
      Map requestParts = (Map) message.getObject();

      // simple part
      Element simplePart = (Element) requestParts.get("simplePart");
      assertTrue(
          DatatypeUtil.toBoolean(
              simplePart.getAttributeNS(
                  BpelConstants.NS_XML_SCHEMA_INSTANCE, BpelConstants.ATTR_NIL)));
      assertFalse(simplePart.hasChildNodes());

      // complex part
      Element complexPart = (Element) requestParts.get("complexPart");
      assertTrue(
          DatatypeUtil.toBoolean(
              complexPart.getAttributeNS(
                  BpelConstants.NS_XML_SCHEMA_INSTANCE, BpelConstants.ATTR_NIL)));
      assertFalse(complexPart.hasChildNodes());
    } finally {
      session.close();
    }
  }
  public void testSendRequest_rpc() throws Exception {
    String requestText =
        "<env:Envelope xmlns:env='"
            + SOAPConstants.URI_NS_SOAP_ENVELOPE
            + "'>"
            + "<env:Body>"
            + "<tns:op xmlns:tns='"
            + BpelConstants.NS_EXAMPLES
            + "'>"
            + "  <simplePart>wazabi</simplePart>"
            + "  <complexPart>"
            + "    <b on='true'>true</b>"
            + "    <c name='venus'/>"
            + "    <d amount='20'/>"
            + "    <e>30</e>"
            + "  </complexPart>"
            + "</tns:op>"
            + "</env:Body>"
            + "</env:Envelope>";
    SOAPMessage soapMessage =
        MessageFactory.newInstance()
            .createMessage(null, new ByteArrayInputStream(requestText.getBytes()));

    Connection connection = integrationControl.getJmsConnection();
    connection.start();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    try {
      SoapHandler soapHandler = createRpcHandler();
      soapHandler.sendRequest(soapMessage, session, jbpmContext);

      PartnerLinkEntry entry =
          integrationControl.getPartnerLinkEntry(Q_RPC_PORT_TYPE, Q_SERVICE, RPC_PORT);
      MessageConsumer consumer = session.createConsumer(entry.getDestination());
      ObjectMessage message = (ObjectMessage) consumer.receiveNoWait();
      Map requestParts = (Map) message.getObject();

      // simple part
      Element simplePart = (Element) requestParts.get("simplePart");
      assertEquals("simplePart", simplePart.getLocalName());
      assertNull(simplePart.getNamespaceURI());
      assertEquals("wazabi", DatatypeUtil.toString(simplePart));

      // complex part
      Element complexPart = (Element) requestParts.get("complexPart");
      assertEquals("complexPart", complexPart.getLocalName());
      assertNull(complexPart.getNamespaceURI());
      assertTrue(complexPart.hasChildNodes());

      // message properties
      assertEquals(
          rpcPartnerLinkId, message.getLongProperty(IntegrationConstants.PARTNER_LINK_ID_PROP));
      assertEquals("op", message.getStringProperty(IntegrationConstants.OPERATION_NAME_PROP));
      assertEquals("venus", message.getStringProperty("nameProperty"));
      assertEquals("30", message.getStringProperty("idProperty"));
    } finally {
      session.close();
    }
  }
  public void testReceiveResponse_output_rpc() throws Exception {
    // prepare messaging objects
    Connection connection = integrationControl.getJmsConnection();
    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    try {
      Destination replyTo =
          integrationControl.getIntegrationServiceFactory().getResponseDestination();
      MessageProducer producer = session.createProducer(replyTo);
      // create parts map
      Map responseParts = createOutputRpcParts();
      // send message to queue
      ObjectMessage jmsResponse = session.createObjectMessage((Serializable) responseParts);
      // use current time in place of the request id
      String requestId = Long.toString(System.currentTimeMillis());
      jmsResponse.setJMSCorrelationID(requestId);
      producer.send(jmsResponse);

      // receive the above message
      SoapHandler soapHandler = createRpcHandler();
      jmsResponse = soapHandler.receiveResponse(session, replyTo, requestId, jbpmContext);
      responseParts = (Map) jmsResponse.getObject();

      // simple part
      Element intPart = (Element) responseParts.get("intPart");
      assertEquals("intPart", intPart.getLocalName());
      assertNull(intPart.getNamespaceURI());
      // value
      assertEquals("2020", DatatypeUtil.toString(intPart));

      // complex part
      Element complexPart = (Element) responseParts.get("complexPart");
      assertEquals("complexPart", complexPart.getLocalName());
      assertNull(complexPart.getNamespaceURI());
      // attributes
      assertEquals("hi", complexPart.getAttribute("attributeOne"));
      assertEquals("ho", complexPart.getAttribute("attributeTwo"));
      // child elements
      Element one = XmlUtil.getElement(complexPart, "urn:uriOne", "elementOne");
      assertEquals("ram", DatatypeUtil.toString(one));
      Element two = XmlUtil.getElement(complexPart, "urn:uriTwo", "elementTwo");
      assertEquals("ones", DatatypeUtil.toString(two));
    } finally {
      session.close();
    }
  }
  public void testWriteOutput_dom_doc() throws Exception {
    SOAPMessage soapMessage = writeDocOutput();

    Element envelopeElem = writeAndRead(soapMessage);
    // soap body
    Element bodyElem = XmlUtil.getElement(envelopeElem, SOAPConstants.URI_NS_SOAP_ENVELOPE, "Body");

    // element part
    Element elementPart =
        XmlUtil.getElement(bodyElem, BpelConstants.NS_EXAMPLES, "responseElement");
    // attributes
    assertEquals("hi", elementPart.getAttribute("attributeOne"));
    assertEquals("ho", elementPart.getAttribute("attributeTwo"));
    // child elements
    Element one = XmlUtil.getElement(elementPart, "urn:uriOne", "elementOne");
    assertEquals("ram", DatatypeUtil.toString(one));
    Element two = XmlUtil.getElement(elementPart, "urn:uriTwo", "elementTwo");
    assertEquals("ones", DatatypeUtil.toString(two));
  }