List of usage examples for javax.xml.ws Service createDispatch
public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode mode)
From source file:org.fireflow.pdl.fpdl.test.service.callback.TheCallbackServiceProcessTest1.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(fireflowRuntimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/*from ww w. ja v a 2 s . com*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { ProcessDescriptor descriptor = stmt.uploadProcessObject(process, 0); ((ProcessDescriptorImpl) descriptor).setPublishState(true); stmt.updateProcessDescriptor(descriptor); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice //TODO WorkflowServer?webservice /* WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ //3??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //?? try { ProcessInstance processInstance = stmt.startProcess(process.getId(), bizId, null); if (processInstance != null) { processInstanceId = processInstance.getId(); } } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WorkflowProcessNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //JaxwsWebservice Environment env = fireflowRuntimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"http://www.fireflow.org/junit/callbackservice\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); Assert.assertEquals(responseResult, response2); this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(fireflowRuntimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/*from w w w. ja v a2s .c om*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { ProcessDescriptor descriptor = stmt.uploadProcessObject(process, 0); ((ProcessDescriptorImpl) descriptor).setPublishState(true); stmt.updateProcessDescriptor(descriptor); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice //TODO WorkflowServer?webservice // WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); // try { // callbackManager.publishAllCallbackServices(); // } catch (WebservicePublishException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } //JaxwsWebservice Environment env = fireflowRuntimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.TheCallbackServiceProcessTest1.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/*from w w w .j ava 2 s . c o m*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //3??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //?? try { ProcessInstance processInstance = stmt.startProcess(process.getId(), bizId, null); if (processInstance != null) { processInstanceId = processInstance.getId(); } } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WorkflowProcessNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"http://www.fireflow.org/junit/callbackservice\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); Assert.assertEquals(responseResult, response2); this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??// w w w. j a v a 2 s . co m final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }
From source file:org.jboss.wsf.test.JBossWSTestHelper.java
private static Object getImplementationObject() { Service service = Service.create(new QName("dummyService")); Object obj = service.getHandlerResolver(); if (obj == null) { service.addPort(new QName("dummyPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://dummy-address"); obj = service.createDispatch(new QName("dummyPort"), Source.class, Mode.PAYLOAD); }/*from www . j av a 2 s.c o m*/ return obj; }
From source file:org.wso2.carbon.connector.rm.ReliableMessage.java
/** * This method used to create dispatcher * * @param inputParams input parameters./*from w w w .ja v a 2s .co m*/ * @return Dispatch source dispatcher * @throws ConnectException */ private Dispatch<Source> createDispatch(RMParameters inputParams, MessageContext messageContext) throws ConnectException { String portName = inputParams.getPortName(); String serviceName = inputParams.getServiceName(); String nameSpace = inputParams.getNamespace(); QName serviceQName = new QName(nameSpace, serviceName); QName portQName = new QName(nameSpace, portName); Service service = Service.create(serviceQName); if (service == null) { String message = "Service instance cannot initialize"; log.error(message); throw new ConnectException(message); } if (RMConstants.SOAP_V_11.equals(inputParams.getSoapVersion())) { service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, inputParams.getEndpoint()); } else { service.addPort(portQName, SOAPBinding.SOAP12HTTP_BINDING, inputParams.getEndpoint()); } Dispatch<Source> sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE); if (messageContext.getSoapAction() != null && !messageContext.getSoapAction().isEmpty()) { sourceDispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, messageContext.getSoapAction()); } return sourceDispatch; }