Can you please help me resolve my errors?
I am self hosting WCF in a WinForm assembly and I am trying to generate the client app.config and service interface. I am executing svcutil http://localhost:8880/MyOwnWCFService/ /Language=c# /t:Code /out:C:\Service\ServiceProxy.cs /config:C:\Service\ServiceProxy.config in the VS2015 developer command prompt.
I get the following errors:
Error: Cannot obtain Metadata from http://localhost:8880/MyOwnWCFService/
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error URI: http://localhost:8880/MyOwnWCFService/
Metadata contains a reference that cannot be resolved: 'http://localhost:8880/MyOwnWCFService/'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:8880/MyOwnWCFService/. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
HTTP GET Error URI: http://localhost:8880/MyOwnWCFService/
There was an error downloading 'http://localhost:8880/MyOwnWCFService/'.
The request failed with the error message:
#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}ServiceService
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. --.
If you would like more help, type "svcutil /?"
My self hosting code:
System.ServiceModel.Channels.Binding MexHttpBinding = MetadataExchangeBindings.CreateMexHttpBinding();
String baseAddress = "http://localhost:8880/MyOwnWCFService/";
NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.None);
tcpbinding.Name = "SEMSIntegration_NetTcpBinding_iSEMSIntegrationWCFService";
tcpbinding.OpenTimeout = new TimeSpan(00, 01, 00);
tcpbinding.CloseTimeout = new TimeSpan(00, 01, 00);
tcpbinding.ReceiveTimeout = new TimeSpan(00, 01, 00);
tcpbinding.SendTimeout = new TimeSpan(00, 01, 00);
tcpbinding.TransactionFlow = false;
tcpbinding.TransferMode = TransferMode.Buffered;
tcpbinding.TransactionProtocol = TransactionProtocol.OleTransactions;
tcpbinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
tcpbinding.ListenBacklog = 10;
tcpbinding.MaxBufferPoolSize = 524288;
tcpbinding.MaxBufferSize = 524288;
tcpbinding.MaxConnections = 100;
tcpbinding.MaxReceivedMessageSize = 524288;
WindowState = FormWindowState.Minimized;
SEMSService = new MyOwnWCFService();
SEMSHost = new ServiceHost(SEMSService, new Uri(baseAddress));
ServiceMetadataBehavior smb = SEMSHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
{
smb = new ServiceMetadataBehavior();
}
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
SEMSHost.Description.Behaviors.Add(smb);
SEMSHost.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
SEMSHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());
SEMSHost.AddServiceEndpoint(typeof(iSEMSIntegrationWCFService), new BasicHttpBinding(), "http://localhost:8880/MyOwnWCFService");
SEMSHost.AddServiceEndpoint(typeof(iSEMSIntegrationWCFService), tcpbinding, "net.tcp://localhost:8888/MyOwnWCFService");
SEMSHost.AddServiceEndpoint("IMetadataExchange", MexHttpBinding, "mex");
SEMSHost.Open();
http://localhost:8880/MyOwnWCFService/wsdl?
? - 500 - Internal Server Error