Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:08:08+00:00 2026-06-14T02:08:08+00:00

I am trying to use my following WCF web service in Android this is

  • 0

I am trying to use my following WCF web service in Android

this is my code

Service

ILoginService

    [ServiceContract]
    public interface ILoginService
    {
        [OperationContract]
        bool LoginUser(string uname, string password);
    }

LoginService.svc.cs

  public class LoginService : ILoginService
    {
        public bool LoginUser(string uname, string password)
        {
            if (uname == password)
                return true;
            else
                return false;
        }
    }

and web.config

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>

      <services>
        <service name="LoginService.LoginService">
          <endpoint binding="basicHttpBinding" contract="LoginService.ILoginService" ></endpoint>  
      </service>
      </services>

      <behaviors>
      <serviceBehaviors>
        <behavior>

          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

  <system.webServer>
    <defaultDocument>
       <files>
        <clear />
        <add value="LoginService.svc" />
      </files>
    </defaultDocument>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
   <handlers>
      <add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="File" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
      <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler" resourceType="File" preCondition="integratedMode"/>
    </handlers>
  </system.webServer>

</configuration>

I have hosted this service on IIS and working well for the dotnet applications.
My android code for accessing this service is

     private void callServiceMethod() throws IOException, XmlPullParserException 
     {
        String NAMESPACE = "http://tempuri.org/";
        String METHOD_NAME = "LoginUser";
        String SOAP_ACTION = "http://tempuri.org/LoginUser";
        String URL = "http://192.168.16.61/LoginService/LoginService.svc";

        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo pi = new PropertyInfo();
        pi.setName("uname");
        pi.setValue("jayant");
        pi.setType(String.class);

        Request.addProperty(pi);

        PropertyInfo pi2 = new PropertyInfo();
        pi2.setName("password");
        pi2.setValue("jayant");
        pi2.setType(String.class);
        Request.addProperty(pi2);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(Request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject response = (SoapObject)envelope.getResponse();
        Result =  Boolean.parseBoolean(response.getProperty(0).toString()) ;
    }

while running this code my program gives exception : XmlpullParserException : End tag expected

Please tell me where I am doing mistake?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:08:09+00:00Added an answer on June 14, 2026 at 2:08 am

    You need specifiy a few attributes for your Operation contract.
    Try something like this:

        [OperationContract()]
    [XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/LoginUser?uname={username}&password={password})]
    bool LoginUser(string uname, string password);
    

    Make sure you don’t use WebMessageBodyStyle.Bare, since this will add unneccesary text to your XML.

    Also consider using JSON with your WCF Service, since JSON is a lot lighter and built in to Android. JSON Homepage Besides adding JSON functionality is very easy in .NET 4+.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use WCF service with raw messages. 1) WCF service code: [DataContract]
I'm trying to use WCF 4 to set up a RESTful web service. I'd
I'm trying to use autofac in the following scenario: A WCF service that, on
I am trying to use a web service built on asp.net wcf from iPhone
I am trying to use the following code, to display $formcode, which is the
I'm trying to use the following code # LOAD XML FILE $XML = new
I'm trying to use the following code to make an image fadeOut and, only
I'm trying to use the following code and it still strips out all the
I'm trying to use the following code (poorly written, but it's just a proof
I’m trying to use the following code in C++ on Mac OS X Snow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.