Comunicação entre Android e um Web Service usando kSOAP

Bom dia.

Estou aprendendo a usar a biblioteca kSOAP mas estou com um problema de comunicação entre um web service na minha maquina e uma aplicação android rodando no emulador.
estou usando esse tutorial: http://www.ibm.com/developerworks/br/library/ws-android/index.html

abaixo esta o codigo do Web Service:

Interface HelloWS

package hello_webservice;

import javax.jws.WebMethod;
import javax.jws.WebService;

/**
 *
 * @author marcelo
 */
@WebService(name="HelloWS",targetNamespace="http://hello_webservice/")
public interface HelloWS 
{
    @WebMethod(operationName = "hello")
    public String hello(String name);
    
}

Implementação da Interface

package hello_webservice;

import javax.jws.WebService;

/**
 *
 * @author marcelo
 */
@WebService(portName = "HelloWSPort", serviceName = "HelloWSService", 
	targetNamespace = "http://hello_webservice/", 
	endpointInterface = "hello_webservice.HelloWS")
public class HelloWSImpl implements HelloWS 
{

    @Override
    public String hello(String name) 
    {
         return "Hello "+name +" Welcome to Web Services!";
    }
    
}

Usei uma aplicação desktop para facilitar o desenvolvimento

package hello_webservice;

import javax.xml.ws.Endpoint;

/**
 *
 * @author marcelo
 */
public class HelloWebService {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        Endpoint.publish("http://127.0.0.1:7001/hello", new HelloWSImpl());
    }
}

Testando a aplicação Web service: http://localhost:7001/hello?wsdl

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. 
-->
<!--
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. 
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://hello_webservice/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://hello_webservice/" name="HelloWSService">
<types>
<xsd:schema>
<xsd:import namespace="http://hello_webservice/" schemaLocation="http://localhost:7001/hello?xsd=1"/>
</xsd:schema>
</types>
<message name="hello">
<part name="parameters" element="tns:hello"/>
</message>
<message name="helloResponse">
<part name="parameters" element="tns:helloResponse"/>
</message>
<portType name="HelloWS">
<operation name="hello">
<input wsam:Action="http://hello_webservice/HelloWS/helloRequest" message="tns:hello"/>
<output wsam:Action="http://hello_webservice/HelloWS/helloResponse" message="tns:helloResponse"/>
</operation>
</portType>
<binding name="HelloWSPortBinding" type="tns:HelloWS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="hello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloWSService">
<port name="HelloWSPort" binding="tns:HelloWSPortBinding">
<soap:address location="http://localhost:7001/hello"/>
</port>
</service>
</definitions>

Codigo da minha aplicação Android

public class MainActivity extends Activity 
{
	private static final String NAMESPACE    ="http://10.0.2.2:7001/";
	private static String URL                ="http://10.0.2.2:7001/hello?wsdl"; 
	private static final String METHOD_NAME  ="hello";
	private static final String SOAP_ACTION  ="http://10.0.2.2:7001/hello";
	

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        TextView lblResult = (TextView) findViewById(R.id.result);
        
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        
        PropertyInfo propInfo = new PropertyInfo();
        propInfo.name="arg0";
        propInfo.type=PropertyInfo.STRING_CLASS;
        request.addProperty(propInfo,"Marcelo Rocha");
        
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        
        try {
			androidHttpTransport.call(SOAP_ACTION, envelope);
			SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
			lblResult.setText(resultsRequestSOAP.toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			Log.i("hello",e.getMessage());
		} catch (XmlPullParserException e) {
			// TODO Auto-generated catch block
			Log.i("hello", e.getMessage());
		}
        
        
        
        
        
    }

No Log da aplicação android eu recebo a seguinte mensagem:
HTTP request failed, HTTP status: 500

No Web Service eu recebo a seguinte mensagem:
Mar 11, 2013 8:20:14 AM com.sun.xml.internal.ws.transport.http.HttpAdapter fixQuotesAroundSoapAction
Advertência: Received WS-I BP non-conformant Unquoted SoapAction HTTP header: http://10.0.2.2:7001/hello

Não consegui descobrir qual o problema :frowning:
Obrigado pelo espaço.

voce nao acha melhor usar Restful?

Muito mais facil, rapido e produtivo, e vc trabalha com XML e JSON :smiley:

Bom dia.
Obrigado pela resposta.

Vou pesquisar Restful :smiley:

Eu gravei uma video aula mostrando como criar um webservice Restful, da uma olhada ai pra vc entender:

Se vc for trabalhar com Android, utilize JSON, consome menos processo =]

Aproveitando, da uma olhada nesses 3 artigos que o Antunes criou, é muito bom, recomendo.

http://www.portalandroid.org/comunidade/viewtopic.php?f=7&t=17389

http://www.portalandroid.org/comunidade/viewtopic.php?f=7&t=17465

http://www.portalandroid.org/comunidade/viewtopic.php?f=7&t=17638