List of usage examples for javax.xml.soap SOAPElement addTextNode
public SOAPElement addTextNode(String text) throws SOAPException;
From source file:com.maxl.java.aips2sqlite.AllDown.java
public void downRefdataPharmaXml(String file_refdata_pharma_xml) { boolean disp = false; ProgressBar pb = new ProgressBar(); try {//from w w w.ja v a2 s . c om // Start timer long startTime = System.currentTimeMillis(); if (disp) System.out.print("- Downloading Refdatabase pharma file... "); else { pb.init("- Downloading Refdatabase pharma file... "); pb.start(); } // Create soaprequest SOAPMessage soapRequest = MessageFactory.newInstance().createMessage(); // Set SOAPAction header line MimeHeaders headers = soapRequest.getMimeHeaders(); headers.addHeader("SOAPAction", "http://refdatabase.refdata.ch/Pharma/Download"); // Set SOAP main request part SOAPPart soapPart = soapRequest.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); // Construct SOAP request message SOAPElement soapBodyElement1 = soapBody.addChildElement("DownloadArticleInput"); soapBodyElement1.addNamespaceDeclaration("", "http://refdatabase.refdata.ch/"); SOAPElement soapBodyElement2 = soapBodyElement1.addChildElement("ATYPE"); soapBodyElement2.addNamespaceDeclaration("", "http://refdatabase.refdata.ch/Article_in"); soapBodyElement2.addTextNode("ALL"); soapRequest.saveChanges(); // If needed print out soapRequest in a pretty format // System.out.println(prettyFormatSoapXml(soapRequest)); // Create connection to SOAP server SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); // wsURL contains service end point String wsURL = "http://refdatabase.refdata.ch/Service/Article.asmx?WSDL"; SOAPMessage soapResponse = connection.call(soapRequest, wsURL); // Extract response Document doc = soapResponse.getSOAPBody().extractContentAsDocument(); String strBody = getStringFromDoc(doc); String xmlBody = prettyFormat(strBody); // Note: parsing the Document tree and using the removeAttribute function is hopeless! xmlBody = xmlBody.replaceAll("xmlns.*?\".*?\" ", ""); long len = writeToFile(xmlBody, file_refdata_pharma_xml); if (!disp) pb.stopp(); long stopTime = System.currentTimeMillis(); System.out.println("\r- Downloading Refdata pharma file... " + len / 1024 + " kB in " + (stopTime - startTime) / 1000.0f + " sec"); connection.close(); } catch (Exception e) { if (!disp) pb.stopp(); System.err.println(" Exception: in 'downRefdataPharmaXml'"); e.printStackTrace(); } }
From source file:com.maxl.java.aips2sqlite.AllDown.java
public void downRefdataPartnerXml(String file_refdata_partner_xml) { boolean disp = false; ProgressBar pb = new ProgressBar(); try {/*from w w w . ja v a 2 s .co m*/ // Start timer long startTime = System.currentTimeMillis(); if (disp) System.out.print("- Downloading Refdata partner file... "); else { pb.init("- Downloading Refdata partner file... "); pb.start(); } // Create soaprequest SOAPMessage soapRequest = MessageFactory.newInstance().createMessage(); // Set SOAPAction header line MimeHeaders headers = soapRequest.getMimeHeaders(); headers.addHeader("SOAPAction", "http://refdatabase.refdata.ch/Download"); // Set SOAP main request part SOAPPart soapPart = soapRequest.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); // Construct SOAP request message SOAPElement soapBodyElement1 = soapBody.addChildElement("DownloadPartnerInput"); soapBodyElement1.addNamespaceDeclaration("", "http://refdatabase.refdata.ch/"); SOAPElement soapBodyElement2 = soapBodyElement1.addChildElement("PTYPE"); soapBodyElement2.addNamespaceDeclaration("", "http://refdatabase.refdata.ch/Partner_in"); soapBodyElement2.addTextNode("ALL"); soapRequest.saveChanges(); // If needed print out soapRequest in a pretty format // System.out.println(prettyFormatSoapXml(soapRequest)); // Create connection to SOAP server SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); // wsURL contains service end point String wsURL = "http://refdatabase.refdata.ch/Service/Partner.asmx?WSDL"; SOAPMessage soapResponse = connection.call(soapRequest, wsURL); // Extract response Document doc = soapResponse.getSOAPBody().extractContentAsDocument(); String strBody = getStringFromDoc(doc); String xmlBody = prettyFormat(strBody); // Note: parsing the Document tree and using the removeAttribute function is hopeless! xmlBody = xmlBody.replaceAll("xmlns.*?\".*?\" ", ""); long len = writeToFile(xmlBody, file_refdata_partner_xml); if (!disp) pb.stopp(); long stopTime = System.currentTimeMillis(); System.out.println("\r- Downloading Refdata partner file... " + len / 1024 + " kB in " + (stopTime - startTime) / 1000.0f + " sec"); connection.close(); } catch (Exception e) { if (!disp) pb.stopp(); System.err.println(" Exception: in 'downRefdataPartnerXml'"); e.printStackTrace(); } }
From source file:com.maxl.java.aips2sqlite.AllDown.java
public void downSwissindexXml(String language, String file_refdata_pharma_xml) { boolean disp = false; ProgressBar pb = new ProgressBar(); try {//w w w. j a va 2s . co m // Start timer long startTime = System.currentTimeMillis(); if (disp) System.out.print("- Downloading Swissindex (" + language + ") file... "); else { pb.init("- Downloading Swissindex (" + language + ") file... "); pb.start(); } SOAPMessage soapRequest = MessageFactory.newInstance().createMessage(); // Setting SOAPAction header line MimeHeaders headers = soapRequest.getMimeHeaders(); headers.addHeader("SOAPAction", "http://swissindex.e-mediat.net/SwissindexPharma_out_V101/DownloadAll"); SOAPPart soapPart = soapRequest.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); // Construct SOAP request message SOAPElement soapBodyElement1 = soapBody.addChildElement("pharmacode"); soapBodyElement1.addNamespaceDeclaration("", "http://swissindex.e-mediat.net/SwissindexPharma_out_V101"); soapBodyElement1.addTextNode("DownloadAll"); SOAPElement soapBodyElement2 = soapBody.addChildElement("lang"); soapBodyElement2.addNamespaceDeclaration("", "http://swissindex.e-mediat.net/SwissindexPharma_out_V101"); if (language.equals("DE")) soapBodyElement2.addTextNode("DE"); else if (language.equals("FR")) soapBodyElement2.addTextNode("FR"); else { System.err.println("down_swissindex_xml: wrong language!"); return; } soapRequest.saveChanges(); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); String wsURL = "https://swissindex.refdata.ch/Swissindex/Pharma/ws_Pharma_V101.asmx?WSDL"; SOAPMessage soapResponse = connection.call(soapRequest, wsURL); Document doc = soapResponse.getSOAPBody().extractContentAsDocument(); String strBody = getStringFromDoc(doc); String xmlBody = prettyFormat(strBody); // Note: parsing the Document tree and using the removeAttribute function is hopeless! xmlBody = xmlBody.replaceAll("xmlns.*?\".*?\" ", ""); long len = writeToFile(xmlBody, file_refdata_pharma_xml); if (!disp) pb.stopp(); long stopTime = System.currentTimeMillis(); System.out.println("\r- Downloading Swissindex (" + language + ") file... " + len / 1024 + " kB in " + (stopTime - startTime) / 1000.0f + " sec"); connection.close(); } catch (Exception e) { if (!disp) pb.stopp(); System.err.println(" Exception: in 'downSwissindexXml'"); e.printStackTrace(); } }
From source file:de.unibi.techfak.bibiserv.BiBiTools.java
/** * Returns a SOAPFaultException with specified * * @param faultcode/* w w w. jav a2 s . c o m*/ * @param faultstring * @param hobitstatuscode * @param hobitstatusdescription * @return */ public static SOAPFaultException createSOAPFaultException(String faultcode, String faultstring, String hobitstatuscode, String hobitstatusdescription) { SOAPFault fault = null; try { SOAPFactory sfi = SOAPFactory.newInstance(); fault = sfi.createFault(); fault.setFaultCode(new QName("http://schemas.xmlsoap.org/soap/envelope/", faultcode, "soap")); fault.setFaultString(faultstring); if (hobitstatuscode != null && hobitstatusdescription != null) { Detail detail = fault.addDetail(); DetailEntry detailentry = detail.addDetailEntry(new QName( "http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "hobitStatuscode", "status")); SOAPElement statuscode = detailentry.addChildElement( new QName("http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "statuscode", "status")); statuscode.addTextNode(hobitstatuscode); SOAPElement description = detailentry.addChildElement(new QName( "http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "description", "status")); description.addTextNode(hobitstatusdescription); } } catch (SOAPException e) { log.fatal("SOAPException occured : " + e.getMessage()); } return new SOAPFaultException(fault); }
From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java
private void addElement(SOAPMessage responseMessage, SOAPEnvelope soapEnvelope, Context context, Element elementToAdd, SOAPElement soapElement) throws SOAPException { SOAPElement soapMethodResponseElement = (SOAPElement) soapEnvelope.getBody().getFirstChild(); String targetNamespace = soapMethodResponseElement.getNamespaceURI(); String prefix = soapMethodResponseElement.getPrefix(); String nodeType = elementToAdd.getAttribute("type"); SOAPElement childSoapElement = soapElement; boolean elementAdded = true; boolean bTable = false; if (nodeType.equals("table")) { bTable = true;//from w w w . j a v a 2s. c o m /*childSoapElement = soapElement.addChildElement("ArrayOf" + context.transactionName + "_" + tableName + "_Row", ""); if (!context.httpServletRequest.getServletPath().endsWith(".wsl")) { childSoapElement.addAttribute(soapEnvelope.createName("xsi:type"), "soapenc:Array"); }*/ childSoapElement = soapElement.addChildElement(elementToAdd.getNodeName()); } else if (nodeType.equals("row")) { /*String elementType = context.transactionName + "_" + tableName + "_Row"; childSoapElement = soapElement.addChildElement(elementType, "");*/ childSoapElement = soapElement.addChildElement(elementToAdd.getNodeName()); } else if (nodeType.equals("attachment")) { childSoapElement = soapElement.addChildElement(elementToAdd.getNodeName()); if (context.requestedObject instanceof AbstractHttpTransaction) { AttachmentDetails attachment = AttachmentManager.getAttachment(elementToAdd); if (attachment != null) { byte[] raw = attachment.getData(); if (raw != null) childSoapElement.addTextNode(Base64.encodeBase64String(raw)); } /* DON'T WORK YET *\ AttachmentPart ap = responseMessage.createAttachmentPart(new ByteArrayInputStream(raw), elementToAdd.getAttribute("content-type")); ap.setContentId(key); ap.setContentLocation(elementToAdd.getAttribute("url")); responseMessage.addAttachmentPart(ap); \* DON'T WORK YET */ } } else { String elementNodeName = elementToAdd.getNodeName(); String elementNodeNsUri = elementToAdd.getNamespaceURI(); String elementNodePrefix = getPrefix(context.projectName, elementNodeNsUri); XmlSchemaElement xmlSchemaElement = getXmlSchemaElementByName(context.projectName, elementNodeName); boolean isGlobal = xmlSchemaElement != null; if (isGlobal) { elementNodeNsUri = xmlSchemaElement.getQName().getNamespaceURI(); elementNodePrefix = getPrefix(context.projectName, elementNodeNsUri); } // ignore original SOAP message response elements // if ((elementNodeName.toUpperCase().indexOf("SOAP-ENV:") != -1) || ((elementToAdd.getParentNode().getNodeName().toUpperCase().indexOf("SOAP-ENV:") != -1)) || // (elementNodeName.toUpperCase().indexOf("SOAPENV:") != -1) || ((elementToAdd.getParentNode().getNodeName().toUpperCase().indexOf("SOAPENV:") != -1)) || // (elementNodeName.toUpperCase().indexOf("NS0:") != -1) || ((elementToAdd.getParentNode().getNodeName().toUpperCase().indexOf("NS0:") != -1))) { // elementAdded = false; // } if ("http://schemas.xmlsoap.org/soap/envelope/".equals(elementToAdd.getNamespaceURI()) || "http://schemas.xmlsoap.org/soap/envelope/" .equals(elementToAdd.getParentNode().getNamespaceURI()) || elementToAdd.getParentNode().getNodeName().toUpperCase().indexOf("NS0:") != -1 || elementNodeName.toUpperCase().indexOf("NS0:") != -1) { elementAdded = false; } else { if (XsdForm.qualified == context.project.getSchemaElementForm() || isGlobal) { if (elementNodePrefix == null) { childSoapElement = soapElement .addChildElement(soapEnvelope.createName(elementNodeName, prefix, targetNamespace)); } else { childSoapElement = soapElement.addChildElement( soapEnvelope.createName(elementNodeName, elementNodePrefix, elementNodeNsUri)); } } else { childSoapElement = soapElement.addChildElement(elementNodeName); } } } if (elementAdded && elementToAdd.hasAttributes()) { addAttributes(responseMessage, soapEnvelope, context, elementToAdd.getAttributes(), childSoapElement); } if (elementToAdd.hasChildNodes()) { NodeList childNodes = elementToAdd.getChildNodes(); int len = childNodes.getLength(); if (bTable) { /*if (!context.httpServletRequest.getServletPath().endsWith(".wsl")) { childSoapElement.addAttribute(soapEnvelope.createName("soapenc:arrayType"), context.projectName+"_ns:" + context.transactionName + "_" + tableName + "_Row[" + (len - 1) + "]"); }*/ } org.w3c.dom.Node node; Element childElement; for (int i = 0; i < len; i++) { node = childNodes.item(i); switch (node.getNodeType()) { case org.w3c.dom.Node.ELEMENT_NODE: childElement = (Element) node; addElement(responseMessage, soapEnvelope, context, childElement, childSoapElement); break; case org.w3c.dom.Node.CDATA_SECTION_NODE: case org.w3c.dom.Node.TEXT_NODE: String text = node.getNodeValue(); text = (text == null) ? "" : text; childSoapElement.addTextNode(text); break; default: break; } } /*org.w3c.dom.Node node; Element childElement; for (int i = 0 ; i < len ; i++) { node = childNodes.item(i); if (node instanceof Element) { childElement = (Element) node; addElement(responseMessage, soapEnvelope, context, childElement, childSoapElement); } else if (node instanceof CDATASection) { Node textNode = XMLUtils.findChildNode(elementToAdd, org.w3c.dom.Node.CDATA_SECTION_NODE); String text = textNode.getNodeValue(); if (text == null) { text = ""; } childSoapElement.addTextNode(text); } else { Node textNode = XMLUtils.findChildNode(elementToAdd, org.w3c.dom.Node.TEXT_NODE); if (textNode != null) { String text = textNode.getNodeValue(); if (text == null) { text = ""; } childSoapElement.addTextNode(text); } } }*/ } }
From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java
private SOAPElement addSoapElement(Context context, SOAPEnvelope se, SOAPElement soapParent, Node node) throws Exception { String prefix = node.getPrefix(); String namespace = node.getNamespaceURI(); String nodeName = node.getNodeName(); String localName = node.getLocalName(); String value = node.getNodeValue(); boolean includeResponseElement = true; if (context.sequenceName != null) { includeResponseElement = ((Sequence) context.requestedObject).isIncludeResponseElement(); }/*from ww w . j a va 2s.c o m*/ SOAPElement soapElement = null; if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; boolean toAdd = true; if (!includeResponseElement && "response".equalsIgnoreCase(localName)) { toAdd = false; } if ("http://schemas.xmlsoap.org/soap/envelope/".equals(element.getParentNode().getNamespaceURI()) || "http://schemas.xmlsoap.org/soap/envelope/".equals(namespace) || nodeName.toLowerCase().endsWith(":envelope") || nodeName.toLowerCase().endsWith(":body") //element.getParentNode().getNodeName().toUpperCase().indexOf("NS0:") != -1 || //nodeName.toUpperCase().indexOf("NS0:") != -1 ) { toAdd = false; } if (toAdd) { if (prefix == null || prefix.equals("")) { soapElement = soapParent.addChildElement(nodeName); } else { soapElement = soapParent.addChildElement(se.createName(localName, prefix, namespace)); } } else { soapElement = soapParent; } if (soapElement != null) { if (soapParent.equals(se.getBody()) && !soapParent.equals(soapElement)) { if (XsdForm.qualified == context.project.getSchemaElementForm()) { if (soapElement.getAttribute("xmlns") == null) { soapElement.addAttribute(se.createName("xmlns"), context.project.getTargetNamespace()); } } } if (element.hasAttributes()) { String attrType = element.getAttribute("type"); if (("attachment").equals(attrType)) { if (context.requestedObject instanceof AbstractHttpTransaction) { AttachmentDetails attachment = AttachmentManager.getAttachment(element); if (attachment != null) { byte[] raw = attachment.getData(); if (raw != null) soapElement.addTextNode(Base64.encodeBase64String(raw)); } /* DON'T WORK YET *\ AttachmentPart ap = responseMessage.createAttachmentPart(new ByteArrayInputStream(raw), element.getAttribute("content-type")); ap.setContentId(key); ap.setContentLocation(element.getAttribute("url")); responseMessage.addAttachmentPart(ap); \* DON'T WORK YET */ } } if (!includeResponseElement && "response".equalsIgnoreCase(localName)) { // do not add attributes } else { NamedNodeMap attributes = element.getAttributes(); int len = attributes.getLength(); for (int i = 0; i < len; i++) { Node item = attributes.item(i); addSoapElement(context, se, soapElement, item); } } } if (element.hasChildNodes()) { NodeList childNodes = element.getChildNodes(); int len = childNodes.getLength(); for (int i = 0; i < len; i++) { Node item = childNodes.item(i); switch (item.getNodeType()) { case Node.ELEMENT_NODE: addSoapElement(context, se, soapElement, item); break; case Node.CDATA_SECTION_NODE: case Node.TEXT_NODE: String text = item.getNodeValue(); text = (text == null) ? "" : text; soapElement.addTextNode(text); break; default: break; } } } } } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { if (prefix == null || prefix.equals("")) { soapElement = soapParent.addAttribute(se.createName(nodeName), value); } else { soapElement = soapParent.addAttribute(se.createName(localName, prefix, namespace), value); } } return soapElement; }
From source file:org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.java
/** * Build SOAPTree Either the root or the parent is null. If the root is null, a new element is * created under the parent using information from the reader If the parent is null, the existing * root is updated with the information from the reader * * @param nc NameCreator//from ww w .jav a 2s.c om * @param root SOAPElement (the element that represents the data in the reader) * @param parent (the parent of the element represented by the reader) * @param reader XMLStreamReader. the first START_ELEMENT matches the root * @param quitAtBody - true if quit reading after the body START_ELEMENT */ protected SOAPElement buildSOAPTree(NameCreator nc, SOAPElement root, SOAPElement parent, XMLStreamReader reader, boolean quitAtBody) throws WebServiceException { try { while (reader.hasNext()) { int eventID = reader.next(); switch (eventID) { case XMLStreamReader.START_ELEMENT: { // The first START_ELEMENT defines the prefix and attributes of the root if (parent == null) { updateTagData(nc, root, reader, false); parent = root; } else { parent = createElementFromTag(nc, parent, reader); if (root == null) { root = parent; } } if (quitAtBody && parent instanceof SOAPBody) { return root; } break; } case XMLStreamReader.ATTRIBUTE: { String eventName = "ATTRIBUTE"; this._unexpectedEvent(eventName); break; } case XMLStreamReader.NAMESPACE: { String eventName = "NAMESPACE"; this._unexpectedEvent(eventName); break; } case XMLStreamReader.END_ELEMENT: { if (parent instanceof SOAPEnvelope) { parent = null; } else { parent = parent.getParentElement(); } break; } case XMLStreamReader.CHARACTERS: { parent.addTextNode(reader.getText()); break; } case XMLStreamReader.CDATA: { parent.addTextNode(reader.getText()); break; } case XMLStreamReader.COMMENT: { // SOAP really doesn't have an adequate representation for comments. // The defacto standard is to add the whole element as a text node. parent.addTextNode("<!--" + reader.getText() + "-->"); break; } case XMLStreamReader.SPACE: { parent.addTextNode(reader.getText()); break; } case XMLStreamReader.START_DOCUMENT: { // Ignore break; } case XMLStreamReader.END_DOCUMENT: { // Close reader and ignore reader.close(); break; } case XMLStreamReader.PROCESSING_INSTRUCTION: { // Ignore break; } case XMLStreamReader.ENTITY_REFERENCE: { // Ignore. this is unexpected in a web service message break; } case XMLStreamReader.DTD: { // Ignore. this is unexpected in a web service message break; } default: this._unexpectedEvent("EventID " + String.valueOf(eventID)); } } } catch (WebServiceException e) { throw e; } catch (XMLStreamException e) { throw ExceptionFactory.makeWebServiceException(e); } catch (SOAPException e) { throw ExceptionFactory.makeWebServiceException(e); } return root; }
From source file:org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.java
private void _fixFaultElements(SOAPEnvelope env) { try {/*www.j a v a 2 s .c om*/ // If we have a SOAP 1.2 envelope, then there's nothing to do. if (env.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { return; } SOAPBody body = env.getBody(); if (body != null && !body.hasFault()) { if (log.isDebugEnabled()) { log.debug("No fault found. No conversion necessary."); } return; } else if (body != null && body.hasFault()) { if (log.isDebugEnabled()) { log.debug("A fault was found. Converting the fault child elements to SOAP 1.1 format"); } SOAPFault fault = body.getFault(); Iterator itr = fault.getChildElements(); while (itr.hasNext()) { SOAPElement se = (SOAPElement) itr.next(); if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) { if (log.isDebugEnabled()) { log.debug("Converting: faultcode"); } // Axis2 SAAJ stores the acutal faultcode text under a SOAPFaultValue object, so we have to // get that and add it as a text node under the original element. Node value = se.getFirstChild(); if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) { org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value; ElementImpl e = valueElement.getElement(); String content = e.getText(); SOAPElement child = fault.addChildElement( new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME)); child.addTextNode(content); se.detachNode(); } } else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) { if (log.isDebugEnabled()) { log.debug("Converting: detail"); } se.setElementQName( new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)); } else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) { if (log.isDebugEnabled()) { log.debug("Converting: faultstring"); } se.setElementQName( new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME)); // Axis2 SAAJ stores the acutal faultstring text under a SOAPFaultValue object, so we have to // get that and add it as a text node under the original element. Node value = se.getFirstChild(); if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) { org.apache.axis2.saaj.SOAPElementImpl valueElement = (org.apache.axis2.saaj.SOAPElementImpl) value; ElementImpl e = valueElement.getElement(); String content = e.getText(); SOAPElement child = fault.addChildElement( new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME)); child.addTextNode(content); se.detachNode(); } } } } } catch (SOAPException e) { if (log.isDebugEnabled()) { log.debug("An error occured while converting fault elements: " + e.getMessage()); } throw ExceptionFactory.makeWebServiceException(e); } }
From source file:org.apache.ws.scout.transport.SaajTransport.java
private void appendElements(SOAPElement bodyElement, NodeList nlist, SOAPFactory factory) throws SOAPException { String prefix = ""; int len = nlist != null ? nlist.getLength() : 0; for (int i = 0; i < len; i++) { Node node = nlist.item(i); short nodeType = node != null ? node.getNodeType() : -100; if (Node.ELEMENT_NODE == nodeType) { Element el = (Element) node; Name name = factory.createName(el.getNodeName(), prefix, UDDI_V2_NAMESPACE); SOAPElement attachedEl = bodyElement.addChildElement(name); appendAttributes(attachedEl, el.getAttributes(), factory); appendElements(attachedEl, el.getChildNodes(), factory); } else if (nodeType == Node.TEXT_NODE) { bodyElement.addTextNode(node.getNodeValue()); }/* w w w. jav a 2 s. c om*/ } }