Hi,
I am trying to consume webservice using java in android app. I am getting 
some error.

THIS IS MY WEBSERVICES:
 
<definitions targetNamespace="http://tempuri.org/type"; 
xmlns="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:wsdlns="http://tempuri.org/wsdl/"; 
xmlns:typens="http://tempuri.org/type";>
    <element name="logon">
    <complexType>
    <sequence>
    <element name="username" type="xsd:string" /> 
    <element name="password" type="xsd:string" /> 
    </sequence>
    </complexType>
    </element>
<portType name="WebServiceSoapPort">
    <operation name="logon">
    <input message="typens:logonrequest" /> 
    <output message="typens:logonresponsetype" /> 
    </operation>

<binding name="WebServiceSoapBinding" type="typens:WebServiceSoapPort">
    <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"; /> 
    <operation name="logon">
    <soap:operation soapAction="" /> //It was empty
    <input>
    <soap:body parts="parameters" use="literal" /> 
    </input>
    <output>
    <soap:body use="literal" /> 
    </output>
    </operation>
<service name="WebService">
    <port name="WebServiceSoapPort" binding="typens:WebServiceSoapBinding">
    <soap:address location="http://raja:90/CRM7/eware.dll/WebServices/SOAP"; 
/> 
    </port>
</service>
</definitions>

THIS IS MY ANDROID CODE:

package com.example.ws1;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity
{
private static final String SOAP_ACTION = “http://tempuri.org/logon”;
private static final String METHOD_NAME = “logon”;
private static final String NAMESPACE = “http://tempuri.org/type”;
private static final String URL = 
“http://192.168.7.86:90/CRM7/eware.dll/webservices.wsdl”;
TextView tv;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tv=(TextView)findViewById(R.id.text1);
call();
}
public void call()
{
try {

PropertyInfo pi = new PropertyInfo();
pi.setName(“username”);
pi.setValue(“admin”);
pi.setName(“password”);
pi.setValue(“test@123?);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty(pi);
//request.addAttribute(“username”, “admin”);
//request.addAttribute(“password”, “test@123?);

SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setAddAdornments(false);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);

HttpTransportSE androidHttpTransports = new HttpTransportSE(URL);
androidHttpTransports.call(SOAP_ACTION, envelope);

SoapObject response = (SoapObject) envelope.bodyIn;
String results = response.getProperty(0).toString();
//Object result = (Object)envelope.getResponse();

tv.setText(results.toString());
} catch (Exception e) {
tv.setText(e.getMessage());
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}

I am calling the method “logon” and passing the parameter as ‘username’ and 
‘password’
after calling that function I am getting an error

org.xmlpull.v1.XmlPullParserException: expected: START_TAG 
{http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG 
@4:81 in java.io.InputStreamReader@4052e620)

I just try to comment the below line also getting same error:
envelope.dotNet=true;

Please any one help on this..!

Regards,
Raja M


On Friday, 22 July 2011 17:47:23 UTC+5:30, rishabh agrawal wrote:
>
> I am beginner in Soap & web service & nothing no how i access web 
> service using wsdl for client request response.Please suggest me where 
> i can start.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to