[Mono-dev] Requested listen uri scheme must be http, but was file
monoUser
cancomert at gmail.com
Mon Jul 30 12:50:42 UTC 2012
Hello,
When I try to open a service host by using following code I get an argument
exception. I am sure that give the schema as http correctly. It works as
expected under windows but under mono it gives the following output..
Thanks in advance,
Regards,
Mehmet Can Comert
CODE
//==========================================================================
private static void
RegisterService<ServiceType>(System.ServiceModel.ServiceHost service_host)
{
string service_type_name = typeof(ServiceType).Name;
string service_address = typeof(ServiceType).Name.Substring(1,
typeof(ServiceType).Name.Length - 8);
Debugger.WriteLine(3, "Registering {0} ({1})...", service_type_name,
service_address);
service_host.AddServiceEndpoint(typeof(ServiceType), new
BasicHttpBinding(),
String.Format("{0}/", service_address))
.Behaviors.Add(new SOAPFaultBehavior());
}
//==========================================================================
public static void Open()
{
Logger.Info("Opening");
System.Diagnostics.Stopwatch stopwatch =
System.Diagnostics.Stopwatch.StartNew();
string host = //ip adress such as 192.168.53.158
int port = //port no
string base_address = String.Format("http://{0}:{1}/PATH/", host,
port);
Console.WriteLine("ServiceHost {0}", base_address);
System.ServiceModel.ServiceHost service_host = new
System.ServiceModel.ServiceHost(typeof(Service), new Uri(base_address));
// +++ Service publishing
++++++++++++++++++++++++++++++++++++++++++++++++
RegisterService<IService>(service_host);
// Metadata publishing...
if(PublishMetadata)
{
Console.WriteLine( "Enabling getting WSDLs...");
service_host.Description.Behaviors.Add(new ServiceMetadataBehavior {
HttpGetEnabled = true });
Console.WriteLine("Registering IMetadataExchange service (mex)...");
service_host.AddServiceEndpoint(typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(), base_address + "mex");
}
Console.WriteLine("Bringing up service class...");
Service.Initialize();
Console.WriteLine( "Opening service host...");
service_host.Open();
m_ServiceHost = service_host;
Logger.Info("OpenedSuccessfully", stopwatch.Elapsed.ToString());
}
--------------
OUTPUT
2012-07-30 14:37:58.495: Opening
ServiceHost http://192.168.53.158:9996/PATH/
RegisterService: None: 3: Registering IService ()...
Enabling getting WSDLs...
Registering IMetadataExchange service (mex)...
Bringing up service class...
Initialize: None: 5: Opening database driver...
Opening service host...
ServiceHost.UnhandledError{System.ArgumentException,Requested listen uri
scheme must be http, but was file.}
Program: Main: Error: 0: EXCEPTION: ArgumentException
Program: Main: Error: 0: Requested listen uri scheme must be http, but was
file.
Program: Main: Error: 0: at
System.ServiceModel.Channels.Http.HttpChannelListener`1[System.ServiceModel.Channels.IReplyChannel]..ctor
(System.ServiceModel.Channels.HttpTransportBindingElement source,
System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename
unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[IReplyChannel]
(System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename
unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel]
() [0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.BindingElement.BuildChannelListener[IReplyChannel]
(System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename
unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.TextMessageEncodingBindingElement.BuildChannelListener[IReplyChannel]
(System.ServiceModel.Channels.BindingContext context) [0x00000] in <filename
unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener[IReplyChannel]
() [0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.Binding.BuildChannelListener[IReplyChannel]
(System.Uri listenUriBaseAddress, System.String listenUriRelativeAddress,
ListenUriMode listenUriMode,
System.ServiceModel.Channels.BindingParameterCollection parameters)
[0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.DispatcherBuilder.BuildListener
(System.ServiceModel.Description.ServiceEndpoint se,
System.ServiceModel.Channels.BindingParameterCollection pl) [0x00000] in
<filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.DispatcherBuilder.BuildChannelDispatcher (System.Type
serviceType, System.ServiceModel.Description.ServiceEndpoint se,
System.ServiceModel.Channels.BindingParameterCollection commonParams)
[0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.ServiceHostBase.InitializeRuntime () [0x00000] in
<filename unknown>:0
Program: Main: Error: 0: at System.ServiceModel.ServiceHostBase.OnOpen
(TimeSpan timeout) [0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout)
[0x00000] in <filename unknown>:0
Program: Main: Error: 0: at
System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in
<filename unknown>:0
Program: Main: Error: 0: ServiceHost.Open () [0x00000] in <filename
unknown>:0
Program: Main: Error: 0: Program.Main (System.String[] args) [0x00000] in
<filename unknown>:0
--------
--
View this message in context: http://mono.1490590.n4.nabble.com/Requested-listen-uri-scheme-must-be-http-but-was-file-tp4650640.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list