Thursday, July 4, 2013

Programmatically create endpoints in .NET WCF webservice

Generate Webservice  proxy class generatedProxy.cs
http://stackoverflow.com/questions/8160176/programmatically-create-endpoints-in-net-wcf-service

http://msdn.microsoft.com/en-us/library/aa395212.aspx

I was getting error while trying to use below code for a secure https channel


using System;
using System.ServiceModel;

namespace ConsoleApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      TimeServiceSoapClient client = 
        new TimeServiceSoapClient(
          new BasicHttpBinding(), 
          new EndpointAddress("http://www.nanonull.com/TimeService/TimeService.asmx"));

      Console.WriteLine(client.getCityTime("London"));
    }
  }
}

Error: The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via

This was fixed after adding below code as explained at http://stackoverflow.com/questions/11563389/custom-binding-the-provided-uri-scheme-https-is-invalid-expected-http-par

var endPoint = new EndpointAddress("https://xxxxx/v2_soap/index/");

var binding = new BasicHttpBinding
{
    Name = "HandlerBinding",
        CloseTimeout = TimeSpan.FromMinutes(1.0),
        HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
        MessageEncoding = WSMessageEncoding.Text,
        MaxReceivedMessageSize = 65536000,
        MaxBufferPoolSize = 65536000,
        UseDefaultWebProxy = true,
        AllowCookies = false,
        BypassProxyOnLocal = false,
        Security =
    {
        Mode =BasicHttpSecurityMode.Transport,
        Transport =
        {
            ClientCredentialType = HttpClientCredentialType.None,
            ProxyCredentialType = HttpProxyCredentialType.None
        },
        Message =
            {
                ClientCredentialType = BasicHttpMessageCredentialType.UserName
            }
    } 
};

Error: The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via
Error: The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via

No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...