Exemple #1
0
  /**
   * This will call the send method on the messages with implicit message parameters or else if
   * there is an endpoint, with that endpoint parameters
   *
   * @param synCtx the current message to be sent
   * @return false always as this is a leaf mediator
   */
  public boolean mediate(SynapseMessageContext synCtx) {

    log.debug("Start : Send mediator");
    if (log.isTraceEnabled()) {
      log.trace("Message : " + synCtx.getEnvelope());
    }

    // if no endpoints are defined, send where implicitly stated
    if (endpoint == null) {

      if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        sb.append("Sending ")
            .append(synCtx.isResponse() ? "response" : "request")
            .append(" message using implicit message properties..");
        sb.append("\nSending To: ")
            .append(synCtx.getTo() != null ? synCtx.getTo().getAddress() : "null");
        sb.append("\nSOAPAction: ")
            .append(synCtx.getWSAAction() != null ? synCtx.getWSAAction() : "null");
        log.debug(sb.toString());
      }

      if (log.isTraceEnabled()) {
        log.trace("Envelope : " + synCtx.getEnvelope());
      }
      synCtx.getEnvironment().send(null, synCtx);

    } else {
      endpoint.send(synCtx);
    }

    log.debug("End : Send mediator");

    return true;
  }
Exemple #2
0
  public static SynapseMessageContext createLightweightSynapseMessageContext(String payload)
      throws Exception {
    MessageContext mc = new OldMessageContext();
    SynapseConfiguration config = new SynapseConfiguration();
    SynapseEnvironment env = new Axis2SynapseEnvironment(config);
    SynapseMessageContext synMc = Axis2SynapseMessageContextImpl.newInstance(mc, config, env);
    SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
    OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
    omDoc.addChild(envelope);

    envelope.getBody().addChild(createOMElement(payload));

    synMc.setEnvelope(envelope);
    return synMc;
  }