This discussion is archived
3 Replies Latest reply: Feb 22, 2010 7:16 AM by 807581 RSS

How to parse xml file, containing image,  generaged from JAX-RS connector?

807581 Newbie
Currently Being Moderated
Hi,
We are using JAX-RS connector and just want to call getBusinessObjects() directly using JerseyMe (basically bypassing sync engine). We have used sync engine so far and want to try as how to bypass it. The method produces the text/xml and verified the xml file in the web by giving the full url. The plan is to call the same URL from the Java Me Client using JerseyMe. When I print the bytes at the client I receive the same xml that I have seen in the web. Actually, I am passing an image that I can see in a different character format in xml (assuming this is bcos of UTF-8 encoding). I am wondering as how to parse this xml file and how to decode the "UTF-8" format? Do we need to use SGMP for this or use kxml or java me webservices spec.

I would really appreciate if somebody can answer this one.

I have been observing in this forum that SGMP team is not at all active in answering the questions. Please let us know whether Oracle is keeping this product and we can continue using SGMP1.1. Please let us know so that we can plan accordingly as we are building a product based on SGMP.
  • 1. Re: How to parse xml file, containing image,  generaged from JAX-RS connect
    807581 Newbie
    Currently Being Moderated
    Hi Rajiv,

    First, note that by getting that JAX-RS resource, you're breaking encapsulation. That is, the format that you're getting back is subject to change. To answer your question, yes you'll need an XML parser like kxml to read the format and extract the BOs from it. Each BO, should have an id and a base64 representation. After decoding the base64 data, you'd need to use the client BO deserializer to interpret the representation.

    As far as the future of SGMP. Oracle has indicated publicly that it intends to invest in the product. We should have more details in the next few weeks. Feel free to ping us again.
  • 2. Re: How to parse xml file, containing image,  generaged from JAX-RS connect
    807581 Newbie
    Currently Being Moderated
    Thanks for getting back to me so quickly and giving an update about the product. This is a very good news. Hopefully we get SGMP1.2, which has many good features, soon.

    I searched for Base64 decoder and could not find in JAVA ME apis. However, I found in Blackberry and since our app is for it we are going to use it. With SGMP1.2, we have plans of supporting in Android and this does not seem to have Base64. I would really appreciate if you can provide the generic Base64 JAVA ME api.
  • 3. Re: How to parse xml file, containing image,  generaged from JAX-RS connect
    807581 Newbie
    Currently Being Moderated
    Hi Rajiv,

    The client library is using org.apache.commons.codec.binary.Base64 internally. We don't have the full Commons Codec library bundled, but you can look up the javadoc for the Base64 class online. All you need to do is call Base64.decode(obj.getBytes()) on the objects you get out of the XML.

    In general it isn't a good idea to depend on implementation details of the client library, but in this case, I think it is pretty safe to expect org.apache.commons.codec.binary.Base64 to remain in our library.

    --Ryan