List of usage examples for javax.xml.stream FactoryConfigurationError getMessage
public String getMessage()
From source file:fileMapper.ws.FileMapperServiceDriver.java
public static String sendSOAP(String requestString, String action, String operation, String type) throws Exception { ServiceClient sender = FileMapperServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);//from w ww . j av a 2 s. c o m opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); // used to be envelope.getBody().getFirstElement().toString() if (type != null) { String request = envelope.toString(); String formattedRequest = XMLUtil.StrFindAndReplace("<", "<", request); if (type.equals("ONT")) { MessageUtil.getInstance().setNavRequest("URL: " + soapEPR + "\n" + formattedRequest); } else { MessageUtil.getInstance().setFindRequest("URL: " + soapEPR + "\n" + formattedRequest); } } operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); if (type != null) { if (type.equals("ONT")) { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setNavResponse("URL: " + soapEPR + "\n" + indentedResponse); } else { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setFindResponse("URL: " + soapEPR + "\n" + indentedResponse); } } // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.eclipse.plugins.patientSet.workplaceMessaging.WorkplaceServiceDriver.java
public static String sendSOAP(String requestString, String action, String operation, String type) throws Exception { ServiceClient sender = WorkplaceServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);//from w w w .j a v a2s . c o m opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); // used to be envelope.getBody().getFirstElement().toString() if (type != null) { String request = envelope.toString(); String formattedRequest = XMLUtil.StrFindAndReplace("<", "<", request); MessageUtil.getInstance().setRequest("URL: " + soapEPR + "\n" + formattedRequest); } operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); if (type != null) { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setResponse("URL: " + soapEPR + "\n" + indentedResponse); } // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.eclipse.plugins.query.workplaceMessaging.WorkplaceServiceDriver.java
public static String sendSOAP(String requestString, String action, String operation, String type) throws Exception { ServiceClient sender = WorkplaceServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);/*from w ww . j a v a 2s .c o m*/ opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); // used to be envelope.getBody().getFirstElement().toString() if (type != null) { String request = envelope.toString(); String formattedRequest = XMLUtil.StrFindAndReplace("<", "<", request); MessageUtil.getInstance().setRequest("URL: " + soapEPR, formattedRequest); } operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); if (type != null) { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setResponse("URL: " + soapEPR, indentedResponse); } // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.utils.PmServiceController.java
public static String sendSOAP(EndpointReference soapEPR, String requestString, String action, String operation) throws Exception { ServiceClient sender = PmServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);/*from w ww.ja va 2 s. c om*/ opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.eclipse.plugins.query.ontologyMessaging.OntServiceDriver.java
public static String sendSOAP(String requestString, String action, String operation, String type) throws Exception { ServiceClient sender = OntServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);/*from w w w .j a va2 s . c o m*/ opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); // used to be envelope.getBody().getFirstElement().toString() if (type != null) { String request = envelope.toString(); String formattedRequest = XMLUtil.StrFindAndReplace("<", "<", request); if (type.equals("ONT")) { MessageUtil.getInstance().setNavRequest("URL: " + soapEPR, formattedRequest); } else { MessageUtil.getInstance().setFindRequest("URL: " + soapEPR, formattedRequest); } } operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); if (type != null) { if (type.equals("ONT")) { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setNavResponse("URL: " + soapEPR, indentedResponse); } else { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setFindResponse("URL: " + soapEPR, indentedResponse); } } // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.eclipse.plugins.explorer.ontologyMessaging.OntServiceDriver.java
public static String sendSOAP(String requestString, String action, String operation, String type) throws Exception { ServiceClient sender = OntServiceClient.getServiceClient(); OperationClient operationClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); // creating message context MessageContext outMsgCtx = new MessageContext(); // assigning message context's option object into instance variable Options opts = outMsgCtx.getOptions(); // setting properties into option log.debug(soapEPR);/*w ww . ja v a 2 s . c om*/ opts.setTo(soapEPR); opts.setAction(action); opts.setTimeOutInMilliSeconds(180000); log.debug(requestString); SOAPEnvelope envelope = null; try { SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); envelope = fac.getDefaultEnvelope(); OMNamespace omNs = fac.createOMNamespace("http://rpdr.partners.org/", "rpdr"); // creating the SOAP payload OMElement method = fac.createOMElement(operation, omNs); OMElement value = fac.createOMElement("RequestXmlString", omNs); value.setText(requestString); method.addChild(value); envelope.getBody().addChild(method); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new Exception(e); } outMsgCtx.setEnvelope(envelope); // used to be envelope.getBody().getFirstElement().toString() if (type != null) { String request = envelope.toString(); String formattedRequest = XMLUtil.StrFindAndReplace("<", "<", request); if (type.equals("ONT")) { MessageUtil.getInstance().setNavRequest("URL: " + soapEPR + "\n" + formattedRequest); } else { MessageUtil.getInstance().setFindRequest("URL: " + soapEPR + "\n" + formattedRequest); } } operationClient.addMessageContext(outMsgCtx); operationClient.execute(true); MessageContext inMsgtCtx = operationClient.getMessageContext("In"); SOAPEnvelope responseEnv = inMsgtCtx.getEnvelope(); OMElement soapResponse = responseEnv.getBody().getFirstElement(); if (type != null) { if (type.equals("ONT")) { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setNavResponse("URL: " + soapEPR + "\n" + indentedResponse); } else { String formattedResponse = XMLUtil.StrFindAndReplace("<", "<", responseEnv.toString()); String indentedResponse = XMLUtil.convertDOMToString(XMLUtil.convertStringToDOM(formattedResponse)); MessageUtil.getInstance().setFindResponse("URL: " + soapEPR + "\n" + indentedResponse); } } // System.out.println("Sresponse: "+ soapResponse.toString()); OMElement soapResult = soapResponse.getFirstElement(); // System.out.println("Sresult: "+ soapResult.toString()); String i2b2Response = soapResult.getText(); log.debug(i2b2Response); return i2b2Response; }
From source file:edu.harvard.i2b2.fr.delegate.pm.PMServiceDriver.java
/** * Function to convert pm requestVdo to OMElement * //from w w w . ja va 2s. com * @param requestPm String request to send to pm web service * @return An OMElement containing the pm web service requestVdo */ public OMElement getPmPayLoad(String requestPm) throws I2B2Exception { OMElement method = null; try { OMFactory fac = OMAbstractFactory.getOMFactory(); //OMNamespace omNs = fac.createOMNamespace("http://www.i2b2.org/xsd/hive/msg", //"i2b2"); //method = fac.createOMElement("request", omNs); StringReader strReader = new StringReader(requestPm); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); method = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new I2B2Exception("", e.getException()); } catch (XMLStreamException e) { log.error(e.getMessage()); throw new I2B2Exception("", e); } return method; }
From source file:edu.harvard.i2b2.crc.loader.delegate.pm.PMServiceDriver.java
/** * Function to convert pm requestVdo to OMElement * //from w w w . j a va 2 s . c o m * @param requestPm * String request to send to pm web service * @return An OMElement containing the pm web service requestVdo */ public OMElement getPmPayLoad(String requestPm) throws I2B2Exception { OMElement method = null; try { OMFactory fac = OMAbstractFactory.getOMFactory(); // OMNamespace omNs = // fac.createOMNamespace("http://www.i2b2.org/xsd/hive/msg", // "i2b2"); // method = fac.createOMElement("request", omNs); StringReader strReader = new StringReader(requestPm); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader reader = xif.createXMLStreamReader(strReader); StAXOMBuilder builder = new StAXOMBuilder(reader); method = builder.getDocumentElement(); } catch (FactoryConfigurationError e) { log.error(e.getMessage()); throw new I2B2Exception("", e.getException()); } catch (XMLStreamException e) { log.error(e.getMessage()); throw new I2B2Exception("", e); } return method; }
From source file:org.apache.rahas.test.util.TestUtil.java
/** * This is directly taken from rampart-core. * TODO we need to move these common code to a new module. Otherwise code will be duplicated. * We cannot use following method from rampart-core as it creates a cyclic dependency. Therefore we have * to live with following./* ww w. j a v a2 s . c om*/ * @param doc The document to convert. * @param useDoom Whether to use doom or not. * @return A SOAPEnvelope. * @throws WSSecurityException If an error occurred during conversion. */ public static SOAPEnvelope getSOAPEnvelopeFromDOMDocument(Document doc, boolean useDoom) throws WSSecurityException { if (useDoom) { try { //Get processed headers SOAPEnvelope env = (SOAPEnvelope) doc.getDocumentElement(); ArrayList processedHeaderQNames = new ArrayList(); SOAPHeader soapHeader = env.getHeader(); if (soapHeader != null) { Iterator headerBlocs = soapHeader.getChildElements(); while (headerBlocs.hasNext()) { OMElement element = (OMElement) headerBlocs.next(); SOAPHeaderBlock header = null; if (element instanceof SOAPHeaderBlock) { header = (SOAPHeaderBlock) element; // If a header block is not an instance of SOAPHeaderBlock, it means that // it is a header we have added in rampart eg. EncryptedHeader and should // be converted to SOAPHeaderBlock for processing } else { header = soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace()); Iterator attrIter = element.getAllAttributes(); while (attrIter.hasNext()) { OMAttribute attr = (OMAttribute) attrIter.next(); header.addAttribute(attr.getLocalName(), attr.getAttributeValue(), attr.getNamespace()); } Iterator nsIter = element.getAllDeclaredNamespaces(); while (nsIter.hasNext()) { OMNamespace ns = (OMNamespace) nsIter.next(); header.declareNamespace(ns); } // retrieve all child nodes (including any text nodes) // and re-attach to header block Iterator children = element.getChildren(); while (children.hasNext()) { OMNode child = (OMNode) children.next(); children.remove(); header.addChild(child); } element.detach(); soapHeader.build(); header.setProcessed(); } if (header.isProcessed()) { processedHeaderQNames.add(element.getQName()); } } } XMLStreamReader reader = ((OMElement) doc.getDocumentElement()).getXMLStreamReader(); SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader); SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope(); //Set the processed flag of the processed headers SOAPHeader header = envelope.getHeader(); for (Iterator iter = processedHeaderQNames.iterator(); iter.hasNext();) { QName name = (QName) iter.next(); Iterator omKids = header.getChildrenWithName(name); if (omKids.hasNext()) { ((SOAPHeaderBlock) omKids.next()).setProcessed(); } } envelope.build(); return envelope; } catch (FactoryConfigurationError e) { throw new WSSecurityException(e.getMessage()); } } else { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); XMLUtils.outputDOM(doc.getDocumentElement(), os, true); ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray()); SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(bais, null); return stAXSOAPModelBuilder.getSOAPEnvelope(); } catch (Exception e) { throw new WSSecurityException(e.getMessage()); } } }
From source file:org.apache.rampart.util.Axis2Util.java
/** * Builds a SOAPEnvelope from DOM Document. * @param doc - The dom document that contains a SOAP message * @param useDoom// w w w . java 2 s . c o m * @return * @throws WSSecurityException */ public static SOAPEnvelope getSOAPEnvelopeFromDOMDocument(Document doc, boolean useDoom) throws WSSecurityException { if (useDoom) { try { //Get processed headers SOAPEnvelope env = (SOAPEnvelope) doc.getDocumentElement(); ArrayList processedHeaderQNames = new ArrayList(); SOAPHeader soapHeader = env.getHeader(); if (soapHeader != null) { Iterator headerBlocs = soapHeader.getChildElements(); while (headerBlocs.hasNext()) { OMElement element = (OMElement) headerBlocs.next(); SOAPHeaderBlock header = null; if (element instanceof SOAPHeaderBlock) { header = (SOAPHeaderBlock) element; // If a header block is not an instance of SOAPHeaderBlock, it means that // it is a header we have added in rampart eg. EncryptedHeader and should // be converted to SOAPHeaderBlock for processing } else { header = soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace()); Iterator attrIter = element.getAllAttributes(); while (attrIter.hasNext()) { OMAttribute attr = (OMAttribute) attrIter.next(); header.addAttribute(attr.getLocalName(), attr.getAttributeValue(), attr.getNamespace()); } Iterator nsIter = element.getAllDeclaredNamespaces(); while (nsIter.hasNext()) { OMNamespace ns = (OMNamespace) nsIter.next(); header.declareNamespace(ns); } // retrieve all child nodes (including any text nodes) // and re-attach to header block Iterator children = element.getChildren(); while (children.hasNext()) { OMNode child = (OMNode) children.next(); child.detach(); header.addChild(child); } element.detach(); soapHeader.build(); header.setProcessed(); } if (header.isProcessed()) { processedHeaderQNames.add(element.getQName()); } } } XMLStreamReader reader = ((OMElement) doc.getDocumentElement()).getXMLStreamReader(); StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(reader, null); SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope(); //Set the processed flag of the processed headers SOAPHeader header = envelope.getHeader(); for (Iterator iter = processedHeaderQNames.iterator(); iter.hasNext();) { QName name = (QName) iter.next(); Iterator omKids = header.getChildrenWithName(name); if (omKids.hasNext()) { ((SOAPHeaderBlock) omKids.next()).setProcessed(); } } envelope.build(); return envelope; } catch (FactoryConfigurationError e) { throw new WSSecurityException(e.getMessage()); } } else { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); XMLUtils.outputDOM(doc.getDocumentElement(), os, true); ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray()); StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder( XMLInputFactory.newInstance().createXMLStreamReader(bais), null); return stAXSOAPModelBuilder.getSOAPEnvelope(); } catch (Exception e) { throw new WSSecurityException(e.getMessage()); } } }