Have reviewed the forum but have not been able to get this code to work properly. New to this and was wondering if someone can help. Thanks in advance
we have a dotNet web service located at http://faxregistration.com/sfaxws/sfaxapi.asmx
The SayHello method requires a request response in xml that also has the userid and password passed
I have the following code trying to make work on the Android
I have also added the permissions in the manifest file and added the ksoap2 jar files as an external jar in the build paths.
I have also tried changing the soap definitions to the http://www.tempuri.org and no luck
package com.android.sfaxservice;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
public class app extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
private static final String SOAP_ACTION = "http://faxregistration.com/sfaxws/SayHello";
private static final String SOAP_METHOD = "SayHello";
private static final String NAMESPACE = "http://faxregistration.com/sfaxws/";
private static final String URL = "http://faxregistration.com/SfaxWS/sfaxapi.asmx";
public void GetData()
{
SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD);
request.addProperty("UserId", "gfry");
request.addProperty("Password","engsystem");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
@SuppressWarnings("unused")
Object result;
try
{
aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
aht.call(SOAP_ACTION, envelope);
result = (Object)envelope.getResponse();
java.lang.String receivedString = (String)envelope.getResponse();
if (receivedString == "Hello From Sfax Web Service");
TextView tv = (TextView)findViewById(R.id.sayhello);
tv.setText("Hello from Sfax Web Service");
} catch (Exception ex) {
result = null;
}
}
}