WebService call under Xamarin.Forms returning incomplete result

Namespace.References is a PCL Profile 78 project containing a reference to a webservice (asmx). Since the profile doesn't support the entire service model stack, only asynchronous methods are generated in the APM style.

When GetLoggedInUser is invoked from a traditional C# console project (referenced as a library) the service invocation completes successfully.

However, when executing the same service call from within a Xamarin.Droid / Xamarin.Forms project the service call completes successfully BUT the response is incomplete. The response only populates an IsSuccessful value found in the base response class.

See below

public partial class GetUserResponse : GatewayResponseBase {

    private User signedInUserField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=0)]
    public User SignedInUser {
        get {
            return this.signedInUserField;
        }
        set {
            this.signedInUserField = value;
            this.RaisePropertyChanged("SignedInUser");
        }
    }
} 

public abstract partial class GatewayResponseBase : object, System.ComponentModel.INotifyPropertyChanged {

    private bool isSuccessfulField;

    private string messageField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=0)]
    public bool IsSuccessful {
        get {
            return this.isSuccessfulField;
        }
        set {
            this.isSuccessfulField = value;
            this.RaisePropertyChanged("IsSuccessful");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=1)]
    public string Message {
        get {
            return this.messageField;
        }
        set {
            this.messageField = value;
            this.RaisePropertyChanged("Message");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}

I invoke the service in the following manner

const string username = "user";
const string password = "pass";
var response = Task<GetUserResponse>.Factory.FromAsync(Service.BeginGetLoggedInUser,
                                                               Service.EndGetLoggedInUser,
                                                               username, password, null).Result;

Under a traditional console app the response.SignedInUser is populated correctly. Invoking the call whilst executing under the mobile platform response.SignedInUser is always null;

The service setup is as below

var service = new SoapClient();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
service.Endpoint.Address = new EndpointAddress("https://address/Service.asmx");
var Service = (IService) service;

Invoking the service in the manner below produces the same result as the associated calls on each platform respectively (i.e. traditional console app vs. mobile platform).

service.GetServicesCompleted += (sender, args) =>
{
   var value = args.Result;
};

service.GetServicesAsync(username, password);

Why would the service call fail in a manner such that only partial information is populated upon completion

ThanksWebService call under Xamarin.Forms returning incomplete result

Sign In or Register to comment.