iOS Development

c# – devour a SOAP api with WCF Service on Xamarin.iOS

Spread the love


I’m dealing with an issue from the previous few days : I wrestle to grasp what I must implement in my Xamarin shopper to keep away from WCF service proxy code era on iOS.

From what I’ve discovered on https://github.com/xamarin/xamarin-macios/points/10737, I must override base TChannel creation methodology from ChannelFactory<TChannel> that’s utilizing dynamic code era.

So I began to override this methodology by merely returning a brand new occasion of the TChannel I wanted :

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
public partial class MySoapServiceClient : System.ServiceModel.ClientBase<MySoapService>, MySoapService
{
    protected override MySoapService CreateChannel()
    {
        return new MySoapServiceClient(EndpointConfiguration.MyEndpointConfiguration);
    }

    public MySoapServiceClient(EndpointConfiguration endpointConfiguration) : 
        base(MySoapServiceClient.GetBindingForEndpoint(endpointConfiguration), MySoapServiceClient.GetEndpointAddress(endpointConfiguration))
    {
        this.Endpoint.Identify = endpointConfiguration.ToString();
        ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
    }
}

Right here is an instance of request applied :

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://myapiservice.com/", ConfigurationName="MyNamespace.MySoapService")]
public interface MySoapService
{
    [System.ServiceModel.OperationContractAttribute(Action="http://myapiservice.com/GetSessionId", ReplyAction="*")]
    [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
    System.Threading.Duties.Process<string> GetSessionIdAsync(string consumer, string pwd);
}

What I can not discover out is : the getter of my ClientBase.Channel which calls this CreateChannel methodology throws an InvalidCastException (I feel it should be on the

return (TChannel)ServiceChannelFactory.CreateChannel<TChannel>(deal with, through);

from ChannelFactory<TChannel>.CreateChannel(EndpointAddress deal with, Uri through)).
I am new to net companies and I do not perceive what my MySoapServiceClient must implement to have the ability to be casted from this methodology, may anybody make clear what precisely ChannelFactory.CreateChannel wants ?

Leave a Reply

Your email address will not be published. Required fields are marked *