Esempio n. 1
0
  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();
    }
  }
Esempio n. 2
0
  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();
    }
  }
Esempio n. 3
0
  private SOAPMessage writeDocOutput() throws Exception {
    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
    Map responseParts = createOutputDocParts();

    SoapHandler soapHandler = createDocHandler();
    soapHandler.writeOutput("op", soapMessage, responseParts);
    return soapMessage;
  }
Esempio n. 4
0
  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();
    }
  }
Esempio n. 5
0
  private SOAPMessage writeFault() throws Exception {
    // soap message
    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();

    // fault exception
    SOAPFaultException faultException =
        new SOAPFaultException(
            SoapBindConstants.CLIENT_FAULTCODE, SoapBindConstants.BUSINESS_FAULTSTRING, null, null);

    // fault parts
    Element faultElem =
        XmlUtil.parseText(
            "<faultElement xmlns='"
                + BpelConstants.NS_EXAMPLES
                + "'>"
                + " <code xmlns=''>100</code>"
                + " <description xmlns=''>unknown problem</description>"
                + "</faultElement>");
    Map faultParts = Collections.singletonMap("faultPart", faultElem);

    SoapHandler soapHandler = createRpcHandler();
    soapHandler.writeFault("op", soapMessage, "flt", faultParts, faultException);
    return soapMessage;
  }