The bad news is: Apache Axis is not in Android BUT the good news is,
you can do this with a simple HTTP POST. Get the SOAP envelope that
Axis generates for you and POST it yourself with something like this:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod( YOUR_ENDPOINT );
postMethod.setRequestHeader( "Content-Type", "text/xml;
charset=utf-8" );
postMethod.setRequestHeader( "SOAPAction", YOUR_OPERATION );
postMethod.setRequestBody( YOUR_SOAP_ENVELOPE );
int statusCode = client.executeMethod( postMethod );
if ( statusCode == 200 ) { // good response
return( postMethod.getStatusLine().toString() );
}
To get the SOAP envelope, start tcpmon or SOAPMonitor and run your
axis code below. Then copy the SOAP from the monitor window and paste
it into your Android code.
If you'd like to expand on that approach, I'd recommend putting the
SOAP in a resource file and merging in arguments such as "Mike".
enjoy!
On Apr 25, 12:19 pm, joesonic <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Is it possible to use SOAP WebServices in Android in a simple way. As
> an example an ordinary java snippet for webservices is given.
>
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import javax.xml.namespace.QName;
> import java.net.*;
>
> public class Test {
> public static void main(String[] args) throws Exception
> {
> Service service = new Service();
> Call call = (Call)service.createCall();
>
> String endpoint = "http://www.example.com/soapserver.php";
> call.setTargetEndpointAddress(new URL(endpoint));
> call.setOperationName(new QName("getName"));
>
> String name= "Mike";
> String result= (String)call.invoke(new Object [] {new
> String(name)});
>
> System.out.println(result);
> }
> }
>
> What's the easiest and fasted way to transfor this for android?
> Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---