示例#1
0
  /** @throws WsdlException */
  public void test() throws WsdlException {
    WsdlDefinitions definitions =
        WsdlResolver.getInstance().loadWsdl(new File(".").toURI(), new File(SAMPLE_AWSDL).toURI());
    URI dscURL = this.configuration.getDSCURL();
    logger.info("dscURL: " + dscURL);
    DSCUtil.convertToCWSDL(definitions, dscURL);

    logger.info(definitions.xmlStringPretty());

    // client
    int clientPort = 0;
    WSIFAsyncResponsesCorrelator correlator = new XsulSoapHttpWsaResponsesCorrelator(clientPort);
    String serverLoc = ((XsulSoapHttpWsaResponsesCorrelator) correlator).getServerLocation();
    logger.info("client is waiting at " + serverLoc);

    // LEAD Context Header
    // Create lead context.
    LeadContextHeaderHelper leadContextHelper = new LeadContextHeaderHelper();
    leadContextHelper.setXBayaConfiguration(this.configuration);
    LeadContextHeader leadContext = leadContextHelper.getLeadContextHeader();
    leadContext.setWorkflowId(URI.create("http://host/2005/11/09/workflowinstace"));
    leadContext.setNodeId("decoder1");
    leadContext.setTimeStep("5");
    leadContext.setServiceInstanceId(URI.create("decoder-instance-10"));

    XmlElement element3 = XMLUtil.xmlElement5ToXmlElement3(definitions.xml());
    xsul.wsdl.WsdlDefinitions definitions3 = new xsul.wsdl.WsdlDefinitions(element3);

    WSIFClient wclient =
        WSIFRuntime.getDefault().newClientFor(definitions3, "TestCMD_Example1SoapPort");
    StickySoapHeaderHandler handler = new StickySoapHeaderHandler("use-lead-header", leadContext);

    wclient.addHandler(handler);
    wclient.useAsyncMessaging(correlator);
    wclient.setAsyncResponseTimeoutInMs(33000L);

    WSIFPort port = wclient.getPort();
    WSIFOperation operation = port.createOperation("Run");
    WSIFMessage inputMessage = operation.createInputMessage();
    WSIFMessage outputMessage = operation.createOutputMessage();
    WSIFMessage faultMessage = operation.createFaultMessage();

    // inputMessage.setObjectPart("InputParam1", "Hello");
    inputMessage.setObjectPart("InputParam1", "100");

    logger.info("inputMessage: " + XsulUtil.safeXmlToString((XmlElement) inputMessage));
    boolean success =
        operation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage);

    XmlElement result;
    if (success) {
      result = (XmlElement) outputMessage;
    } else {
      result = (XmlElement) faultMessage;
    }
    logger.info("result:\n" + XsulUtil.safeXmlToString(result));
  }
示例#2
0
 /**
  * @param url
  * @param args
  * @param opName
  * @return The output
  * @throws ComponentRegistryException
  */
 public WSIFMessage sendSOAPMessage(String url, Object[][] args, String opName)
     throws ComponentRegistryException {
   WSIFClient wclient = WSIFRuntime.newClient(url);
   return sendSOAPMessage(wclient, args, opName);
 }