Retrieving XML Document from web service

by beacon » Sat, 31 Jul 2010 06:35:25 GMT


Sponsored Links
 Hi ,

 I am trying to retrieve a XML document from web service. I am passing
a soap object with a token implementing the OAuth concept and
retrieving the data. But the data does not turn out to be in XML
format. It contains a curly braces in the place of start tag and
semicolons when it ends. Is there any way to retrieve the document in
XML format as such?

Thank you

Beacon

--



Retrieving XML Document from web service

by Carlos Silva » Sat, 31 Jul 2010 06:39:58 GMT


Retrieving XML Document from web service

by beacon » Sat, 31 Jul 2010 06:45:43 GMT


 Thanks for your reply. But it is not similar to JSON. My sample data
looks something like this

anyType{ProductName=anyType{Text=Nadolol; Code=anyType{Value=11755;
CodingSystem=FDB_routed; }; Code=anyType{Value=20.55472;
CodingSystem=Google; }; Code=anyType{Value=7870; CodingSystem=FDB; };
Code=anyType{Value=19.9453; CodingSystem=Google; }; }; }

And I have confirmed with the web service and they have assured that
they send back the data in XML format. But I am not able to get it in
XML format.







--



Retrieving XML Document from web service

by Frank Weiss » Sat, 31 Jul 2010 07:06:01 GMT


 I don't recognize what data format that is, but I would guess that
your code has an error or is not sending the right HTTP headers. What
client side code are you using?

--



Retrieving XML Document from web service

by beacon » Sat, 31 Jul 2010 07:29:16 GMT


 Hello Frank,

This is what I am doing on the client side

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("token",WebPage.token);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=
\"UTF-8\"?>");
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
String strResult = result.toString();

I am getting all the fields that I am supposed to get, but I am not
getting it in the XML format.That's my problem.




--



Retrieving XML Document from web service

by Filip Havlicek » Sun, 01 Aug 2010 13:08:14 GMT


 Hi,

just a quick thought about that - some web services have a request property
to define in what format you want the result. Are you sure this isn't your
case?

Best regards,
Filip Havlicek

2010/7/31 beacon <indiantalkiedhi...@gmail.com>


>



Retrieving XML Document from web service

by Ed » Mon, 02 Aug 2010 10:56:31 GMT


 Add this for all the classes you're using. This will let KSoap2 know
what java classes handle the each response element.

    envelope.addMapping(request.getNamespace(),
                        "MyDotNetClassName",
                        MyAndroidClass.class);

For others trying to help this is the KSoap2 toString() once KSoap2
has parsed the XML response.

Ed





--



Retrieving XML Document from web service

by CMF » Mon, 02 Aug 2010 11:26:59 GMT


 I dont know if it is suitable for your case, but I can retrieve the
xml document for the web with the following method

URL mURL= new URL("http://XXXXX/a.xml");
http = (HttpURLConnection) mURL.openConnection();
int nRC = http.getResponseCode();
if (nRC == HttpURLConnection.HTTP_OK)
{
        DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document dom = builder.parse(mURL.openConnection().getInputStream());
        Element root = dom.getDocumentElement();
        NodeList items = root.getElementsByTagName("item");
        for(int i=0; i<items.getLength(); i++)
        {
                Node property = properties.item(j);
                String name = property.getNodeName();
                if (name.equalsIgnoreCase("property1))
                {
                        Log.d("Property1", 
property.getFirstChild().getNodeValue());
                }
        }
}

//a.xml
<root>
        <item>
                <property1>Iamproperty1</property1>
        </item>
</root>




--



Retrieving XML Document from web service

by beacon » Mon, 02 Aug 2010 22:13:42 GMT


 Hi Filip,

  It doesn't seem to be the case, as the web service does not give me
any option it just sends XML response whatever it is.




> >



Retrieving XML Document from web service

by beacon » Mon, 02 Aug 2010 22:16:18 GMT


 Hello Ed,

   Thanks for your response. I added the code snippet to me requesting/
receiving class . But  I still get the response in the same format as
mentioned above. I am not sure why.

beacon






--



Retrieving XML Document from web service

by beacon » Mon, 02 Aug 2010 22:17:21 GMT


 Hello CMF,

             Thanks for your reply. But I dont think I can use this
kind of approach as I need to send a soap object to the web service
and nothing else and it also implements OAuth.

beacon





--



Retrieving XML Document from web service

by Filip Havlicek » Mon, 02 Aug 2010 23:07:59 GMT


 Hi Beacon,

it would probably be the best if you could give as a link to the service you
are trying to use. We could at least look into the website to see if you are
not missing something, because this just doesn't look like XML at all afaik.

Best regards,
Filip Havlicek

2010/8/2 beacon <indiantalkiedhi...@gmail.com>



> > >



Retrieving XML Document from web service

by beacon » Mon, 02 Aug 2010 23:33:14 GMT


 Hi Filip,

  Thanks for your reply. Sure I could give that. This is the what I am
trying to access.

      private static final String NAMESPACE = " http://tempuri.org/" ;;
        private static final String METHOD_NAME = "GetProfileDataXML";
        private static final String URL = " http://mobileexchange.ctisinc.com/ 
CTISGDataService.svc";
        private static final String SOAP_ACTION = " http://tempuri.org/ 
ICTISGDataService/GetProfileDataXML";



With regards,

Beacon





> > > >



Retrieving XML Document from web service

by Bob Kerns » Tue, 03 Aug 2010 01:23:29 GMT


 hat Ed is telling you (and the other people trying to help) is that
what you are seeing is NOT the format that the server is ending.

In fact, it would be somewhat difficult for you to actually see that
data in your program and also parse it.

What you are seeing is the result of (implicitly) calling toString()
on the objects that are being returned, which is in a compact format
intended for developers. Not necessarily a good format, but that's
basically irrelevant. You are not having the problem you think you are
having!

The fact that you are getting this output at all means that you ARE
successfully receiving and parsing the XML. In fact, from the presence
of the 'anyType' tokens, I am guessing it has even been through XML
Schema Validation.

If you wanted to see the actual data, you'd have to open the
connection yourself using the same URL, post the same data if using
POST, and then read the result as a series bytes, convert to
characters (using a Reader) and output the result. I haven't a clue
how you'd manage to do this and get KSoap to also process it; I
wouldn't even try.

So the bottom line is -- the problem you think you face basically
doesn't exist. Your next step is to make use of that returned data
through the provided APIs.

On Aug 2, 7:15am, beacon <indiantalkiedhi...@gmail.com> wrote:

--



Retrieving XML Document from web service

by beacon » Tue, 03 Aug 2010 03:06:00 GMT


 hanks for your reply Bob. I got hold of whats happening now. I will
look in to it. Thank you,

Beacon

On Aug 2, 1:23pm, Bob Kerns <r...@acm.org> wrote:

--



Other Threads

1. Help Required in Android Porting in DM6467

Hello,
       I am planning to port android in DM6467 evaluation board. Could
anyone share necessary guidelines for android porting to this board
and share difficulties faced when ported android to this particular
board. Please share more technical details if you have.
Thanks in advance.
-Anurag

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Releasing Apps with Android OS Revisions

About to release an app.

Tell me if you build an app for 1.5 will does that mean it can install and run 
on all phones from 1.5 forward ?
[1.6, 2.x ....]

-- 

3. Emulator Internet Connectivity Problem

4. Buttons looking weird when they are too small

5. ask : 3 (three) gagal connect di spica

6. Registering with the USB HID CLASS Driver

7. kmemtrace