Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a php webservice
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello',                // method name
    array('name' => 'xsd:string'),        // input parameters
    array('return' => 'xsd:string'),      // output parameters
    'urn:hellowsdl',                      // namespace
    'urn:hellowsdl#hello',                // soapaction
    'rpc',                                // style
    'encoded',                            // use
    'Says hello to the caller'            // documentation
);

function hello($name) {
        return 'Hello, ' . $name;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

And my java client (android device)

private static final String SOAP_ACTION = "urn:hellowsdl#hello";
	private static final String METHOD_NAME = "hello";
	private static final String NAMESPACE = "urn:hellowsdl";
	private static final String URL = "http://127.0.0.1/www/webs.php";


	@Override
	public void onCreate(Bundle icicle)
	{
		super.onCreate(icicle);
		TextView tv = new TextView(this);
		setContentView(tv);


		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);


		//SoapObject 
		request.addProperty("name", "name");


		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);

		HttpTransportSE httpTransport = new HttpTransportSE(URL);

		try
		{
			httpTransport.call(SOAP_ACTION, envelope);
			Object response = envelope.getResponse();
			tv.setText(response.toString());
		}

		catch (Exception exception)
		{
			tv.setText(exception.toString());
		}

	}

But I always get connection refused. What am I doing wrong ?
Posted
Updated 14-Jul-11 7:00am
v4
Comments
Maxdd 7 14-Jul-11 13:01pm    
Edited question.

It doesn't matter what created your webservice, the way webservices behave conforms to a standard. Therefore, if your service is correctly written, any tutorial online about how to call a webservice through android, should work.
 
Share this answer
 
Comments
Maxdd 7 13-Jul-11 19:27pm    
Updated my question.
Solved with

private static final String URL = "http://10.0.2.2/www/webs.php";


Looks like Android emulator uses 127.0.0.1 that's why does not work.
 
Share this answer
 
Nice tutorial to start with SOAP

i need to develop web services for media upload work in php can you suggest me what should i prefer either core php or SOAP with multipart .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900