Namespace.References- A PCL project Profile 78containing a link to a web service ( asmx). Because the profile does not support the entire stack of the service model, only asynchronous methods are generated in the APM style.
When GetLoggedInUsercalled from a traditional C # console project (referred to as a library), the service call succeeds.
However, when making the same service call from the project, Xamarin.Droid / Xamarin.Formsthe service call succeeds, but the answer is incomplete. The response only fills the value IsSuccessfulfound in the base class of the response.
See below
public partial class GetUserResponse : GatewayResponseBase {
private User signedInUserField;
[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;
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public bool IsSuccessful {
get {
return this.isSuccessfulField;
}
set {
this.isSuccessfulField = value;
this.RaisePropertyChanged("IsSuccessful");
}
}
[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 call the service as follows
const string username = "user";
const string password = "pass";
var response = Task<GetUserResponse>.Factory.FromAsync(Service.BeginGetLoggedInUser,
Service.EndGetLoggedInUser,
username, password, null).Result;
response.SignedInUser . response.SignedInUser null;
var service = new SoapClient();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
service.Endpoint.Address = new EndpointAddress("https://address/Service.asmx");
var Service = (IService) service;
, (.. ).
service.GetServicesCompleted += (sender, args) =>
{
var value = args.Result;
};
service.GetServicesAsync(username, password);
, .