List of usage examples for javax.xml.soap SOAPElement setTextContent
public void setTextContent(String textContent) throws DOMException;
From source file:net.bpelunit.framework.control.deploy.ode.ODERequestEntityFactory.java
private void prepareUndeploySOAP(String packageId) throws SOAPException, IOException { MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage message = mFactory.createMessage(); SOAPBody body = message.getSOAPBody(); SOAPElement xmlUndeploy = body.addChildElement(ODE_ELEMENT_UNDEPLOY); SOAPElement xmlPackageName = xmlUndeploy.addChildElement(ODE_ELEMENT_PACKAGENAME); xmlPackageName.setTextContent(packageId); ByteArrayOutputStream b = new ByteArrayOutputStream(); message.writeTo(b);/*from w ww . ja v a 2 s.c om*/ fContent = b.toString(); }
From source file:net.bpelunit.framework.control.deploy.ode.ODERequestEntityFactory.java
private void prepareDeploySOAP(File file) throws IOException, SOAPException { MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage message = mFactory.createMessage(); SOAPBody body = message.getSOAPBody(); SOAPElement xmlDeploy = body.addChildElement(ODE_ELEMENT_DEPLOY); SOAPElement xmlZipFilename = xmlDeploy.addChildElement(ODE_ELEMENT_ZIPNAME); xmlZipFilename.setTextContent(FilenameUtils.getName(file.toString()).split("\\.")[0]); SOAPElement xmlZipContent = xmlDeploy.addChildElement(ODE_ELEMENT_PACKAGE); SOAPElement xmlBase64ZipFile = xmlZipContent.addChildElement(ODE_ELEMENT_ZIP, "dep", NS_DEPLOY_SERVICE); xmlBase64ZipFile.addAttribute(new QName(NS_XML_MIME, CONTENT_TYPE_STRING), ZIP_CONTENT_TYPE); StringBuilder content = new StringBuilder(); byte[] arr = FileUtils.readFileToByteArray(file); byte[] encoded = Base64.encodeBase64Chunked(arr); for (int i = 0; i < encoded.length; i++) { content.append((char) encoded[i]); }//from w ww. j ava 2 s . c o m xmlBase64ZipFile.setTextContent(content.toString()); ByteArrayOutputStream b = new ByteArrayOutputStream(); message.writeTo(b); fContent = b.toString(); }
From source file:net.bpelunit.framework.control.deploy.activebpel.BPRDeployRequestEntity.java
@Override protected void populateMessage(SOAPMessage message) throws SOAPException, IOException { SOAPElement xmlDeployBpr = addRootElement(message, new QName(ACTIVEBPEL_ELEMENT_DEPLOYBPR)); // Add filename SOAPElement xmlBprFilename = xmlDeployBpr.addChildElement(ACTIVEBPEL_ELEMENT_ABPRFILENAME); xmlBprFilename.addAttribute(new QName(ActiveBPELRequestEntityBase.NS_XMLSCHEMA_INSTANCE, "type"), XSD_STRING);/*from www . j a v a2s . com*/ xmlBprFilename.setTextContent(FilenameUtils.getName(file.toString())); // Add data SOAPElement xmlBase64File = xmlDeployBpr.addChildElement(ACTIVEBPEL_ELEMENT_ABASE64FILE); xmlBase64File.addAttribute(new QName(ActiveBPELRequestEntityBase.NS_XMLSCHEMA_INSTANCE, "type"), XSD_STRING); StringBuilder content = new StringBuilder(); byte[] arr = FileUtils.readFileToByteArray(file); byte[] encoded = Base64.encodeBase64Chunked(arr); for (int i = 0; i < encoded.length; i++) { content.append((char) encoded[i]); } xmlBase64File.setTextContent(content.toString()); }
From source file:com.jkoolcloud.tnt4j.streams.custom.inputs.CastIronWsStream.java
/** * Appends SOAP request message with {@code "sessionId"} header having token received from scenario {@code "login"} * step and saved in streams cache.//from w w w.ja v a 2 s. c om * * @param soapRequest * SOAP request message instance * @throws javax.xml.soap.SOAPException * if there was an error adding the SOAP message header */ @Override protected void addSoapHeaders(SOAPMessage soapRequest) throws SOAPException { SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPElement sessionIdElem = soapFactory.createElement("sessionId", "sec", // NON-NLS "http://www.approuter.com/schemas/2008/1/security"); // NON-NLS String cachedToken = String.valueOf(StreamsCache.getValue(tokenCacheKey)); logger().log(OpLevel.DEBUG, StreamsResources.getBundle(WsStreamConstants.RESOURCE_BUNDLE_NAME), "CastIronStream.adding.req.header", sessionIdElem.getLocalName(), cachedToken); sessionIdElem.setTextContent(cachedToken); soapRequest.getSOAPHeader().addChildElement(sessionIdElem); }
From source file:org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider.java
public Source invoke(Source request) { Source response = null;// www. ja v a 2 s . c o m try { RequestSecurityTokenType rst = convertToJAXBObject(request); Object operationImpl = null; List<?> objectList = rst.getAny(); for (int i = 0; i < objectList.size(); i++) { Object obj = objectList.get(i); if (obj instanceof JAXBElement) { QName qname = ((JAXBElement<?>) obj).getName(); if (qname.equals(new QName(WSTRUST_13_NAMESPACE, WSTRUST_REQUESTTYPE_ELEMENTNAME))) { operationImpl = operationMap.get(((JAXBElement<?>) obj).getValue().toString()); break; } } } if (operationImpl == null) { throw new Exception("Implementation for this operation not found."); } Method[] methods = operationImpl.getClass().getMethods(); for (int x = 0; x < methods.length; x++) { Class<?>[] paramClass = methods[x].getParameterTypes(); if (paramClass.length == 1 && paramClass[0].equals(rst.getClass())) { RequestSecurityTokenResponseCollectionType tokenResponse = (RequestSecurityTokenResponseCollectionType) methods[x] .invoke(operationImpl, rst); if (tokenResponse == null) { throw new Exception("Error in implementation class."); } response = new JAXBSource(jaxbContext, new ObjectFactory().createRequestSecurityTokenResponseCollection(tokenResponse)); return response; } } } catch (Exception e) { LOG.error(e); try { SOAPFault fault = soapFactory.createFault(); if (e.getMessage() == null) { fault.setFaultString(e.getCause().getMessage()); } else { fault.setFaultString(e.getMessage()); } Detail detail = fault.addDetail(); detail = fault.getDetail(); QName qName = new QName(WSTRUST_13_NAMESPACE, "Fault", "ns"); DetailEntry de = detail.addDetailEntry(qName); qName = new QName(WSTRUST_13_NAMESPACE, "ErrorCode", "ns"); SOAPElement errorElement = de.addChildElement(qName); StackTraceElement[] ste = e.getStackTrace(); errorElement.setTextContent(ste[0].toString()); throw new SOAPFaultException(fault); } catch (SOAPException e1) { LOG.error(e1); } } return response; }