C# web service wrapper on new net core/standard frame

I’m trying to develop a c# wrapper to communicate with x3 SOAP web services with the new frameworks NET CORE, NET STANDARD 2.0 (on Xamarin).

With this wrapper:

https://www.rklesolutions.com/blog/x3-soap-web-services

I can easily connect with old NET Framework, but in Net Core SoapHttpClientProtocol is no more supported and can’t override GetWebRequest.

So I follow this stackoverflow: 

https://stackoverflow.com/questions/48625444/calling-a-soap-service-in-net-core

 

I share my solution on net core (but at the moment it doesn’t work),  you find the new service reference (obtained from the wizard on net core):

https://codeshare.io/al6xZD

and my client method class:

https://codeshare.io/5eExZK

When I run the getdescription method I don't get any errors, but the application times out.

Can you help me in any way?

  • 0

    Hi,

    Did have any luck with this issue? I´m having the same problem.

  • 0

    I am in the same boat. Any progress on this ?

  • 0

    I was able to manually inject authorization like so

    public class ClientMessageInspector : IClientMessageInspector
    {
    public void AfterReceiveReply(ref Message reply, object correlationState)
    {
    // Nothing Here
    Console.Write(reply.ToString());
    }

    public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
    HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
    httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
    Convert.ToBase64String(Encoding.ASCII.GetBytes("username" + ":" +
    "password));
    request.Properties.Add(HttpRequestMessageProperty.Name, httpRequestProperty);
    return null;
    }
    }

    public class CustomEndpoint : IEndpointBehavior
    {
    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
    {
    // Nothing here
    }

    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
    {
    clientRuntime.ClientMessageInspectors.Add(new ClientMessageInspector());
    }

    public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
    {
    // Nothing here
    }

    public void Validate(ServiceEndpoint endpoint)
    {
    // Nothing here
    }
    }

    And adding the custom endpoint to the proxy 

    var proxy = new CAdxWebServiceXmlCCClient();
    proxy.Endpoint.EndpointBehaviors.Add(new CustomEndpoint());

    However, I had issue with the client deserialization that was throwing an error.