RE: URGENT:!!! Please help insert XML data in kSOAP envelope
<[email protected]> Thu, 30 Oct 2003 14:30:06 +0200
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Message-ID | <[email protected]> |
Hi,
:-(
well, i don't know exactly how ur application is written, but things that come
to my mind are:
- write recursive call that parses the returned XML , and from that build a SoapObject. it's long time
that i don't write parsing code :-(, i usually do it with SAX, but i don't know if the query is generated
on the Mobile Device) . this can be tough (altough not impossible :-) because i don't know if the query
has 'same structure' but different value
- write some sort of XML 2 Java code, so you will have an Object out of your query, maybe an Hashtable? so
that u can separate name/value for each property..
what prevents me from giving u new ideas is that i don't know how ur application is structured.....
where is the query generated and where it is passed?
is the Mobile device that has to generate the object?
if u are building a SoapObject, i assume at that moment u are on the mobile device.
So, from what i can see the flow of action is:
- mobile device call serverside
- serverside executes query and return XML to the device
- device builds a SoapObject to be sent-... where?
can u give me hint on what ur app is? i m sure there is a way to do that....
regards
marco
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of ext KHOURY Shérine (Dr&T)
Sent: 30 October, 2003 15:14
To: [email protected]
Subject: Re: Ksoap: URGENT:!!! Please help insert XML data in kSOAP envelope
[email protected] wrote:
Hi
i am using following code for inserting
<agency>
<name>..</name>
<tel>..</tel>
<email>..</email>
<contacted>...</contacted>
<contactPerson>...</contactPerson>
</agency>
on the receiving side (struts/servlet) i can successfully build a SOAPEnvelope..
SoapObject method = new SoapObject( "http://www.tgmm.com/agenciesdemo" <http://www.tgmm.com/agenciesdemo> , "agency");
method.addProperty("name", name);
method.addProperty("tel", phone);
method.addProperty("email", email);
method.addProperty("contacted", contact);
method.addProperty("contactperson",person);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapSerializationEnvelope.VER10);
envelope.bodyOut = method;
System.err.println("connecting to new endpoint...");
HttpTransport ht = new HttpTransport( "http://localhost:8080/struts/insert.do" <http://localhost:8080/struts/insert.do> );// http://services.xmethods.net/soap");
ht.debug = true;
try {
ht.call( "http://localhost:8080/struts/insert.do" <http://localhost:8080/struts/insert.do> , envelope);
}
catch (Exception e) {
e.printStackTrace();
}
hope this helps...
regards
marco
-----Original Message-----
From: [email protected] [ mailto:[email protected]]On Behalf Of ext KHOURY Shérine (Dr&T)
Sent: 29 October, 2003 16:16
To: [email protected]
Subject: Ksoap: URGENT:!!! Please help insert XML data in kSOAP envelope
Hi guys,
I have to send an XML result looking like this
<Person>
<FirstName>Smith</FirstName>
<LastName>John</LastName>
</Person>
inside a SOAP message using kSOAP.
I'm proceding as follows:
//result being a String containing the XML result
response = new SoapObject( soapReq.getNamespace( ) , name + "Response" );
if ( result != null )
response.addProperty( "return", result );
}
SoapEnvelope ResEnv = new SoapEnvelope();
// Puts the Soap response in the envelope's body
ResEnv.setBody(response);
The problem is that upon receipt of this Soap message, the contents of the SOAP envelope looks something like this:
<SOAP-ENV:Envelope xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" <http://www.w3.org/2001/XMLSchema-instance> xmlns:xsd= "http://www.w3.org/2001/XMLSchema" <http://www.w3.org/2001/XMLSchema> xmlns:SOAP-ENC= "http://schemas.xmlsoap.org/soap/encoding/" <http://schemas.xmlsoap.org/soap/encoding/> xmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/" <http://schemas.xmlsoap.org/soap/envelope/> >
<SOAP-ENV:Body SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" <http://schemas.xmlsoap.org/soap/encoding/> >
<findResponse xmlns="urn:sncf:profilekeeper:profilekeeper.ProfileKeeper" id="o0" SOAP-ENC:root="1">
<return xmlns="" xsi:type="xsd:string"><Person>
<FirstName>Smith</FirstName>
<LastName>John</LastName>
<Person>
</return>
</findResponse>
</SOAP-ENV:Body>
Can anyone tell me how to avoid letting SoapObject assume all properties to be Strings?
I'm in urgent need of help!! So I will appreciate any suggestions
Hello Marco,
Thanks for your help. But my problem is that in my case, the XML part that I need to add in the SOAP message does not have a standard structure. It's the answer returned by some query, so it's really dependant of that query.
Therefore what you suggested does not exactly fit to what I want to do. Do you have any more ideas?
Thanks anyway!!
Shérine