/** * @param wclient * @param args * @param opName * @return The output * @throws ComponentRegistryException */ public WSIFMessage sendSOAPMessage(WSIFClient wclient, Object[][] args, String opName) throws ComponentRegistryException { WSIFPort port = wclient.getPort(); WSIFOperation operation = port.createOperation(opName); WSIFMessage outputMessage = operation.createOutputMessage(); WSIFMessage faultMessage = operation.createFaultMessage(); String messageName = operation.createInputMessage().getName(); XmlElement inputMsgElem = builder.newFragment(this.requestNS, messageName); for (int i = 0; i < args.length; i++) { createMessage((String) args[i][0], args[i][1], inputMsgElem); } WSIFMessageElement inputMessage = new WSIFMessageElement(inputMsgElem); boolean success = operation.executeRequestResponseOperation(inputMessage, outputMessage, faultMessage); if (success) { logger.debug("" + outputMessage); return outputMessage; } else { throw new ComponentRegistryException("Excpetion at server " + faultMessage); } }
/** @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)); }