org.apache.axis.encoding.DeserializationContext Java Examples

The following examples show how to use org.apache.axis.encoding.DeserializationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BinaryDeserializer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * On end element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @throws SAXException the SAX exception
 * @see org.apache.axis.encoding.Deserializer#onEndElement(java.lang.String, java.lang.String,
 *      org.apache.axis.encoding.DeserializationContext)
 */
@Override
public void onEndElement(String arg0, String arg1, DeserializationContext arg2)
        throws SAXException {
  try {
    // System.out.println("onEndElement(" + arg0 + "," + arg1 + ")");

    // deserialize (if not done already via attachments)
    if (this.getValue() == null) {
      // System.out.println("deserializing - no attachments found"); //DEBUG
      String base64str = buf.toString();
      // System.out.println("Base64str: " + base64str);
      if (base64str.length() > 0) {
        byte[] bytes = Base64.decode(base64str);
        setValue(SerializationUtils.deserialize(bytes));
      }
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new SAXException(e);
  }
}
 
Example #2
Source File: BinaryDeserializer_Axis11.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * On end element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @throws SAXException the SAX exception
 * @see org.apache.axis.encoding.Deserializer#onEndElement(java.lang.String, java.lang.String,
 *      org.apache.axis.encoding.DeserializationContext)
 */
@Override
public void onEndElement(String arg0, String arg1, DeserializationContext arg2)
        throws SAXException {
  try {
    // System.out.println("onEndElement(" + arg0 + "," + arg1 + ")");

    // deserialize (if not done already via attachments)
    if (this.getValue() == null) {
      // System.out.println("deserializing - no attachments found"); //DEBUG
      String base64str = buf.toString();
      // System.out.println("Base64str: " + base64str);
      if (base64str.length() > 0) {
        byte[] bytes = Base64.decode(base64str);
        setValue(SerializationUtils.deserialize(bytes));
      }
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new SAXException(e);
  }
}
 
Example #3
Source File: XmlDeserializer_Axis11.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * On end element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @throws SAXException the SAX exception
 * @see org.apache.axis.encoding.Deserializer#onEndElement(java.lang.String, java.lang.String,
 *      org.apache.axis.encoding.DeserializationContext)
 */
@Override
public void onEndElement(String arg0, String arg1, DeserializationContext arg2)
        throws SAXException {
  // System.out.println("AxisResourceServiceDeserializer::onEndElement(" + arg0 + "," + arg1);
  mNesting--;

  if (mNesting > 0) {
    mDeser.endElement(arg0, arg1, arg1);
  }
}
 
Example #4
Source File: XmlDeserializer_Axis11.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * On start element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @param arg3 the arg 3
 * @param arg4 the arg 4
 * @throws SAXException the SAX exception
 * @see org.apache.axis.message.SOAPHandler#onStartChild(String, String, String, Attributes, DeserializationContext)
 */
@Override
public void onStartElement(String arg0, String arg1, String arg2, Attributes arg3,
        DeserializationContext arg4) throws SAXException {
  // System.out.println("AxisResourceServiceDeserializer::onStartElement(" + arg0 + "," + arg1 +
  // "," + arg2 + ")");

  // don't process the topmost element - it is a SOAP "multiRef" element and
  // we don't care about that
  if (mNesting > 0) {
    mDeser.startElement(arg0, arg1, arg1, arg3);
  }
  mNesting++;
}
 
Example #5
Source File: XmlDeserializer.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * On start element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @param arg3 the arg 3
 * @param arg4 the arg 4
 * @throws SAXException the SAX exception
 * @see org.apache.axis.message.SOAPHandler#onStartChild(String, String, String, Attributes, DeserializationContext)
 */
@Override
public void onStartElement(String arg0, String arg1, String arg2, Attributes arg3,
        DeserializationContext arg4) throws SAXException {
  // System.out.println("AxisResourceServiceDeserializer::onStartElement(" + arg0 + "," + arg1 +
  // "," + arg2 + ")");

  // don't process the topmost element - it is a SOAP "multiRef" element and
  // we don't care about that
  if (mNesting > 0) {
    mDeser.startElement(arg0, arg1, arg1, arg3);
  }
  mNesting++;
}
 
Example #6
Source File: XmlDeserializer.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * On end element.
 *
 * @param arg0 the arg 0
 * @param arg1 the arg 1
 * @param arg2 the arg 2
 * @throws SAXException the SAX exception
 * @see org.apache.axis.encoding.Deserializer#onEndElement(java.lang.String, java.lang.String,
 *      org.apache.axis.encoding.DeserializationContext)
 */
@Override
public void onEndElement(String arg0, String arg1, DeserializationContext arg2)
        throws SAXException {
  // System.out.println("AxisResourceServiceDeserializer::onEndElement(" + arg0 + "," + arg1);
  mNesting--;

  if (mNesting > 0) {
    mDeser.endElement(arg0, arg1, arg1);
  }
}
 
Example #7
Source File: AxisDeserializer.java    From googleads-java-lib with Apache License 2.0 4 votes vote down vote up
public <ResultT> List<ResultT> deserializeBatchJobMutateResults(
    URL url,
    List<TypeMapping> serviceTypeMappings,
    Class<ResultT> resultClass,
    QName resultQName,
    int startIndex,
    int numberResults)
    throws Exception {

  List<ResultT> results = Lists.newArrayList();

  // Build a wrapped input stream from the response.
  InputStream wrappedStream =
      ByteSource.concat(
              ByteSource.wrap(SOAP_START_BODY.getBytes(UTF_8)),
              batchJobHelperUtility.buildWrappedByteSource(url, startIndex, numberResults),
              ByteSource.wrap(SOAP_END_BODY.getBytes(UTF_8)))
          .openStream();

  // Create a MessageContext with a new TypeMappingRegistry that will only
  // contain deserializers derived from serviceTypeMappings and the
  // result class/QName pair.
  MessageContext messageContext = new MessageContext(new AxisClient());
  TypeMappingRegistryImpl typeMappingRegistry = new TypeMappingRegistryImpl(true);
  messageContext.setTypeMappingRegistry(typeMappingRegistry);

  // Construct an Axis deserialization context.
  DeserializationContext deserializationContext =
      new DeserializationContext(
          new InputSource(wrappedStream), messageContext, Message.RESPONSE);

  // Register all type mappings with the new type mapping registry.
  TypeMapping registryTypeMapping =
      typeMappingRegistry.getOrMakeTypeMapping(messageContext.getEncodingStyle());
  registerTypeMappings(registryTypeMapping, serviceTypeMappings);

  // Parse the wrapped input stream.
  deserializationContext.parse();

  // Read the deserialized mutate results from the parsed stream.
  SOAPEnvelope envelope = deserializationContext.getEnvelope();
  MessageElement body = envelope.getFirstBody();

  for (Iterator<?> iter = body.getChildElements(); iter.hasNext(); ) {
    Object child = iter.next();
    MessageElement childElm = (MessageElement) child;
    @SuppressWarnings("unchecked")
    ResultT mutateResult = (ResultT) childElm.getValueAsType(resultQName, resultClass);
    results.add(mutateResult);
  }
  return results;
}
 
Example #8
Source File: BinaryDeserializer.java    From uima-uimaj with Apache License 2.0 2 votes vote down vote up
/**
 * On start element.
 *
 * @param namespace the namespace
 * @param localName the local name
 * @param prefix the prefix
 * @param attributes the attributes
 * @param context the context
 * @throws SAXException the SAX exception
 * @see org.apache.axis.message.SOAPHandler#onStartChild(String, String, String, Attributes, DeserializationContext)
 */
@Override
public void onStartElement(String namespace, String localName, String prefix,
        Attributes attributes, DeserializationContext context) throws SAXException {
  buf.setLength(0);
}
 
Example #9
Source File: BinaryDeserializer_Axis11.java    From uima-uimaj with Apache License 2.0 2 votes vote down vote up
/**
 * On start element.
 *
 * @param namespace the namespace
 * @param localName the local name
 * @param prefix the prefix
 * @param attributes the attributes
 * @param context the context
 * @throws SAXException the SAX exception
 * @see org.apache.axis.message.SOAPHandler#onStartChild(String, String, String, Attributes, DeserializationContext)
 */
@Override
public void onStartElement(String namespace, String localName, String prefix,
        Attributes attributes, DeserializationContext context) throws SAXException {
  buf.setLength(0);
}
 
Example #10
Source File: XmlDeserializer_Axis11.java    From uima-uimaj with Apache License 2.0 2 votes vote down vote up
/**
 * This method is invoked when an element start tag is encountered.
 *
 * @param namespace          is the namespace of the element
 * @param localName          is the name of the element
 * @param prefix          is the element's prefix
 * @param attributes          are the attributes on the element...used to get the type
 * @param context          is the DeserializationContext
 * @return the SOAP handler
 * @throws SAXException the SAX exception
 */
@Override
public SOAPHandler onStartChild(String namespace, String localName, String prefix,
        Attributes attributes, DeserializationContext context) throws SAXException {
  return this;
}
 
Example #11
Source File: XmlDeserializer.java    From uima-uimaj with Apache License 2.0 2 votes vote down vote up
/**
 * This method is invoked when an element start tag is encountered.
 *
 * @param namespace          is the namespace of the element
 * @param localName          is the name of the element
 * @param prefix          is the element's prefix
 * @param attributes          are the attributes on the element...used to get the type
 * @param context          is the DeserializationContext
 * @return the SOAP handler
 * @throws SAXException the SAX exception
 */
@Override
public SOAPHandler onStartChild(String namespace, String localName, String prefix,
        Attributes attributes, DeserializationContext context) throws SAXException {
  return this;
}