Examples of StreamSource


Examples of javax.xml.transform.stream.StreamSource

    }
   
    @SuppressWarnings("unchecked")
  public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
    if (sourceClass == null || sourceClass == StreamSource.class) {
      return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId());
    } else if (sourceClass == StAXSource.class) {
      XMLInputFactory factory = XMLInputFactory.newInstance();
      try {
        return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream()));
      } catch (XMLStreamException e) {
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

        List<Argument> arguments = this.procedure.getArguments();
       
        String style = (String)arguments.get(0).getArgumentValue().getValue();
        String action = (String)arguments.get(1).getArgumentValue().getValue();
        XMLType docObject = (XMLType)arguments.get(2).getArgumentValue().getValue();
        StreamSource source = null;
      try {
          source = convertToSource(docObject);
          String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
         
          if (style == null) {
            style = executionFactory.getDefaultBinding().getBindingId();
          } else {
            try {
              Binding type = Binding.valueOf(style.toUpperCase());
              style = type.getBindingId();
            } catch (IllegalArgumentException e) {
              throw new TranslatorException(WSExecutionFactory.UTIL.getString("invalid_invocation", Arrays.toString(Binding.values()))); //$NON-NLS-1$
            }
          }
         
          Dispatch<StreamSource> dispatch = conn.createDispatch(style, endpoint, StreamSource.class, executionFactory.getDefaultServiceMode());
 
      if (Binding.HTTP.getBindingId().equals(style)) {
        if (action == null) {
          action = "POST"; //$NON-NLS-1$
        }
        dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, action);
        if (source != null && !"POST".equalsIgnoreCase(action)) { //$NON-NLS-1$
          if (this.executionFactory.getXMLParamName() == null) {
            throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
          }
          try {
            Transformer t = TransformerFactory.newInstance().newTransformer();
            StringWriter writer = new StringWriter();
            //TODO: prevent this from being too large
                t.transform(source, new StreamResult(writer));
            String param = Util.httpURLEncode(this.executionFactory.getXMLParamName())+"="+Util.httpURLEncode(writer.toString()); //$NON-NLS-1$
            endpoint = WSConnection.Util.appendQueryString(endpoint, param);
          } catch (TransformerException e) {
            throw new WebServiceException(e);
          }
        }
      } else {
        if (action != null) {
          dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
          dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, action);
        }
      }
     
      if (source == null) {
        // JBoss Native DispatchImpl throws exception when the source is null
        source = new StreamSource(new StringReader("<none/>")); //$NON-NLS-1$
      }
      this.returnValue = dispatch.invoke(source);
    } catch (SQLException e) {
      throw new TranslatorException(e);
    } catch (WebServiceException e) {
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

       
    @Test public void testGetSource() throws Exception {       
        SQLXMLImpl xml = new SQLXMLImpl(testStr);
        assertTrue(xml.getSource(null) instanceof StreamSource);
       
        StreamSource ss = (StreamSource)xml.getSource(null);
        assertEquals(testStr, new String(ObjectConverterUtil.convertToByteArray(ss.getInputStream()), Streamable.ENCODING));
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

        "      </publishingInformation>\r\n" //$NON-NLS-1$
        "   </book>\r\n" + //$NON-NLS-1$
        "</Books:bookCollection>"; //$NON-NLS-1$
  
    public void testStreamSourceWithStream() throws Exception {
        StandardXMLTranslator translator = new StandardXMLTranslator(new StreamSource(new StringReader(sourceXML)));
        compareDocuments(sourceXML, translator.getString());
    }   
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

      try {
        if (value instanceof SQLXML) {
        return ((SQLXML)value).getSource(null);
        }
        if (value instanceof Clob) {
          return new StreamSource(((Clob)value).getCharacterStream());
        }
        if (value instanceof Blob) {
          return new StreamSource(((Blob)value).getBinaryStream());
        }
        if (value instanceof String) {
          return new StreamSource(new StringReader((String)value));
        }
      } catch (SQLException e) {
      throw new TeiidProcessingException(e);
    }
      throw new AssertionError("Unknown type"); //$NON-NLS-1$
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

            ContentDisposition disp = new ContentDisposition(contentDisposition.get(0));
            if(disp.getParameter("name") != null && disp.getParameter("name").equals(propertyName)){
              if(clazz.isAssignableFrom(DataHandler.class))
                return new DataHandler(new MimePartDataSource(new MimeBodyPart(mimePart.read())));
              else if(clazz.isAssignableFrom(javax.xml.transform.Source.class))
                return new StreamSource(mimePart.read());
            }
          } catch (Exception e) {
            if(this.traceEnabled){
              traceLog.error(String.format("Error while handling attachment name:\"%s\". message: \"%s\"",
                  propertyName,e.getMessage()));
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

  public @WebResult(name="albums") FeedType listAlbums(@WebParam(name = "crediential") Crediential crediential) {
    try {
      //TODO from JNDI property
      URL       albumURL   = new URL("http://picasaweb.google.com/data/feed/api/user/"+crediential.getUsername()+"?kind=album");
      Unmarshaller   um       = context.createUnmarshaller();
      FeedType ob = um.unmarshal(new StreamSource(albumURL.openStream()),FeedType.class).getValue();
      return ob;
    } catch (Exception e) {
      e.printStackTrace();
      throw new Error("Album request failed",e);
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

          @WebParam(name = "albumUrl", partName = "albumUrl")
          String albumUrl) {
    try {
      URL       albumURL   = new URL(albumUrl);
      Unmarshaller   um       = context.createUnmarshaller();
      FeedType ob = um.unmarshal(new StreamSource(albumURL.openStream()),FeedType.class).getValue();
      return ob;
    } catch (Exception e) {
      e.printStackTrace();
      throw new Error("Album request failed",e);
    }
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

  @Override
  public XMLStreamOutput getXmlStream(TestInput arg0) {
    XMLStreamOutput xml = new XMLStreamOutput();
    xml.setOutputFormates("application/xml");
    // File or any source
    xml.setXml(new StreamSource(ChartPortImpl.class.getResourceAsStream("test.xml")));
    return xml;
  }
View Full Code Here

Examples of javax.xml.transform.stream.StreamSource

    @Override
    public void transform() throws Exception {
        TransformerFactory factory = TransformerFactory.newInstance();
        FileOutputStream fos = new FileOutputStream(target.toString());
        javax.xml.transform.Transformer transformer =
                              factory.newTransformer(new StreamSource(template.toString()));
        transformer.transform(new StreamSource(source.toString()),
                              new StreamResult(fos));
       
        fos.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.