yes, NameValuePair("Fahrenheit","23") would be pretty cute, but it's up to you if you want to do the "footwork" - i.e. is it worth it for your app?. In my case, I went for the simplest processing I could think of - it's dirty but it's quick :
a) replace the arguments in the SOAP envelopes with delimited tokens, eg. %degrees% :
<soap:Envelope ...
<soap:Body> ...
<Fahrenheit>%degrees%</Fahrenheit>
</soap:Body>
</soap:Envelope>
b) put the SOAP envelopes in raw resource files, eg. YOUR_PROJECT/res/raw/fahrenheit
c) invoke the snippet below with something like this:
String [] args = { "212" };
postMethod.setRequestBody( mergeArguments( R.raw.fahrenheit, args ) );
/*
* This reads in the raw soap xml file given by rId and merges in arguments given by args[].
* The soap file contains tokens of the form '%arg%' and each time such a token is found,
* the next args[] is substituted in the xml. If more tokens than args[] are found, then
* the last args[] is used repeatedly.
*/
private String mergeArgument( int rId, String [] args ) {
String xml = "";
int currentArgIndex = 0;
int noArgs = args.length;
Resources resources = getResources();
InputStream xmlStream = resources.openRawResource( rId );
try {
while ( true ) {
int b = xmlStream.read();
if ( b < 1 ) break; // EOF
if ( ( char )b == '%' ) { // substitute next args[]
xml += args[ currentArgIndex ];
if ( currentArgIndex < noArgs - 1 ) currentArgIndex++;
do { // skip input to end of token
b = xmlStream.read();
if ( b < 1 ) break; // EOF
}
while ( ( char )b != '%' );
}
else xml += String.valueOf( ( char )b );
}
xmlStream.close();
}
catch ( IOException e ) {
Log.e( tag, "IOException'" + e.toString() );
}
return( xml );
}
enjoy!
P.S. don't forget postMethod.releaseConnection();
joesonic wrote:
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-no... For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~--- |
- [android-developers] Android and Web Services joesonic
- [android-developers] Re: Android and Web Services joesonic
- [android-developers] Re: Android and Web Services sauhund
- [android-developers] Re: Android and Web Services joesonic
- [android-developers] Re: Android and Web Services mathiastck
- [android-developers] Re: Android and Web Services Bruno Sauer
- [android-developers] Re: Android and Web Serv... Dorothy
- [android-developers] Re: Android and Web... Mark Murphy
- [android-developers] Re: Android and... Dorothy
- [android-developers] Re: Android... Mark Murphy

