I am currently working on a C# project which is a console app which has a WCF soap service hosted within it.
Below is the code I am using to open the host.
var baseAddress = new Uri(Configuration.soapServerSettings.soapServerUrl);
var host = new ServiceHost(typeof(SoapServer), baseAddress);
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
var meta = new ServiceMetadataBehavior()
{
HttpGetEnabled = true,
HttpGetUrl = new Uri("", UriKind.Relative)
};
host.Description.Behaviors.Add(meta);
var debugBehaviour = new ServiceDebugBehavior()
{
HttpHelpPageEnabled = true,
HttpHelpPageUrl = new Uri("", UriKind.Relative),
IncludeExceptionDetailInFaults = true
};
ServiceEndpoint endpnt = host.AddServiceEndpoint(
typeof(ISoapInterface),
basicHttpBinding,
"EmailServer");
host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
host.Description.Behaviors.Add(debugBehaviour);
host.Open();
This is working perfectly fine on Windows but on Linux when I get I browse to it I get the following message:
XmlSchema error: Named item http://schemas.microsoft.com/2003/10/Serialization/:anyType was already contained in the schema object table. Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation. Related schema item SourceUri: , Line 3, Position 3.
I have no idea where to start looking into this problem.
Thanks for any help you can provide
Update:
As per Rob Goodwins suggestion, I've added the MONO_STRICT_MS_COMPLIANT
as the environment variable which does seem to have worked I can access the service. However, I am getting a different problem now. I have a PHP page which does several requests every couple of seconds but then after a minute, my app crashes.
I get the following exception:
This XmlWriter does not accept StartTag at this state Error. at System.Xml.XmlTextWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in :0 at System.Xml.DefaultXmlWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00000] in :0 at System.Xml.XmlWriter.WriteStartElement (System.String localName, System.String ns) [0x00000] in :0 at System.ServiceModel.Logger.TraceCore (TraceEventType eventType, Int32 id, Boolean hasRelatedActivity, Guid relatedActivity, System.Object[] data) [0x00000] in :0 at System.ServiceModel.Logger.LogMessage (System.ServiceModel.Diagnostics.MessageLogTraceRecord log) [0x00000] in :0 at System.ServiceModel.Logger.LogMessage (MessageLogSourceKind sourceKind, System.ServiceModel.Channels.Message& msg, Int64 maxMessageSize) [0x00000] in :0 at System.ServiceModel.Channels.Http.HttpRequestContext.InternalReply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in :0 at System.ServiceModel.Channels.Http.HttpRequestContext.Reply (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.MessageProcessingContext.Reply (Boolean useTimeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.OperationInvokerHandler.Reply (System.ServiceModel.Dispatcher.MessageProcessingContext mrc, Boolean useTimeout) [0x00000] in :0 at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0 at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest (System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in :0
Unhandled Exception: System.InvalidOperationException: This XmlWriter does not accept StartTag at this state Error. at System.Xml.XmlTextWriter.WriteStartElement (System.String prefix, System.String localName, System.String namespaceUri) [0x00000] in :0 at System.Xml.DefaultXmlWriter.WriteStartElement (System.String prefix, System.String localName, System.String ns) [0x00000] in :0 at System.Xml.XmlWriter.WriteStartElement (System.String localName, System.String ns) [0x00000] in :0 at System.ServiceModel.Logger.TraceCore (TraceEventType eventType, Int32 id, Boolean hasRelatedActivity, Guid relatedActivity, System.Object[] data) [0x00000] in :0 at System.ServiceModel.Logger.Log (TraceEventType eventType, System.String message, System.Object[] args) [0x00000] in :0 at System.ServiceModel.Logger.Error (System.String message, System.Object[] args) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessErrorWithHandlers (IChannel ch, System.Exception ex, System.ServiceModel.Channels.Message& res) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.ProcessRequest (IReplyChannel reply, System.ServiceModel.Channels.RequestContext rc) [0x00000] in :0 at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x00000] in :0
I also don't seem to be able to access the service via VS2010 WCF Test Client, it doesn't error it just sits there with the progress bar at 50% and doesn't get any further.
In the apache error log I get the following error:
System.ArgumentException: Should be something like [[hostname:]port:]VPath:realpath at Mono.WebServer.ApplicationServer.AddApplicationsFromCommandLine (System.String applications) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:AddApplicationsFromCommandLine (string) at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool) at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Should be something like [[hostname:]port:]VPath:realpath at Mono.WebServer.ApplicationServer.AddApplicationsFromCommandLine (System.String applications) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:AddApplicationsFromCommandLine (string) at Mono.WebServer.Apache.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in :0 at (wrapper remoting-invoke-with-check) Mono.WebServer.Apache.Server:RealMain (string[],bool,Mono.WebServer.IApplicationHost,bool) at Mono.WebServer.Apache.Server.Main (System.String[] args) [0x00000] in :0
Update 2: I seem to have it kind of working now except I can only access the service locally. I.e. the web service can be accessed locally and the functions do what they should, but I can't access it from another PC. I.e. I am trying to access the WCF service on the Mono server using the WCF test client from my dev PC from dev PC and I am then getting the following output:
Error: Cannot obtain Metadata from
http://192.168.1.74:6525/
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://192.168.1.74:6525/
Metadata contains a reference that cannot be resolved:'http://192.168.1.74:6525/
'.
Content Type application/soap+xml; charset=utf-8 was not supported by servicehttp://192.168.1.74:6525/
. The client and service bindings may be mismatched. The remote server returned an error: (415) Expected content-type 'text/xml; charset=utf-8' but got 'application/soap+xml; charset=utf-8'.HTTP GET Error URI:http://192.168.1.74:6525/
The document was understood, but it could not be processed. - The WSDL document contains links that could not be resolved. - There was an error downloading 'http://localhost:6525/?xsd=xsd0
'. - Unable to connect to the remote server - No connection could be made because the target machine actively refused it 127.0.0.1:6525.
Update 3: Upon further testing it looks as if when many calls are made into the service in one go. Constantly hiting refresh on the browser page making use of the service seems to crash it.
It looks as if there is something wrong with the System.ServiceModel.Logger.TraceCore
within Mono. Is there a way to disable this part of mono so I don't get affected by this issue.