WCF Service hosted in Azure Cloud Service errors after published - wcf

I have a project with several WCF services (mix of REST and SOAP). The project has been running On-Prem for 6 months without an issue. We are moving this to Azure but have run into an issue that will prevent us from going live.
The project uses Autofac for it's IOC. We are gonig to host this in a Cloud Service in Azure. Everything appears to work correctly when running locally in the Azure Emulator however once we deploy using the Cloud Service project, everything builds and deploys correctly, but we receive the following error when trying to access a service.
Server Error in '/' Application.
Value cannot be null. Parameter name: key
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: key Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Value cannot be null.
Parameter name: key]
System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) +48
System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +38
System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +20
System.ServiceModel.Dispatcher.WebHttpDispatchOperationSelector..ctor(ServiceEndpoint endpoint) +2459
System.ServiceModel.Description.WebHttpBehavior.GetOperationSelector(ServiceEndpoint endpoint) +125
System.ServiceModel.Description.WebHttpBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) +1955
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +4245
System.ServiceModel.ServiceHostBase.InitializeRuntime() +119
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +45
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +553
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +350
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1614
[ServiceActivationException: The service '/Event/Calendar' cannot be activated due to an exception during compilation. The exception message is: Value cannot be null.
Parameter name: key.]
System.Runtime.AsyncResult.End(IAsyncResult result) +925
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +528
System.ServiceModel.Activation.AspNetRouteServiceHttpHandler.EndProcessRequest(IAsyncResult result) +107
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +151
It appears that it's having an issue with the service configuration endpoint. That is registered through Autofac WCF integration using the OOTB RouteTable here:
RouteTable.Routes.Add(new ServiceRoute("Event/Calendar", new AutofacWebServiceHostFactory(), typeof(CalendarSvc)));
All of this works fine in IIS and the local Azure emulator, but once deployed to the cloud service is where we get an issue.

Observed exactly problem. Solved by canceling IntelliTrace on this hosted service.
I did publishing from VS2013 and marked "Enable IntelliTrace" during publishing. Once I canceled this option and re-publish - all works properly....

Related

BizTalk WCF Service Publishing Wizard to expose schemas as WCF service issue when browse services through IIS

Server Error in '/OrderProcessingService' Application.
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Can someone help to resolve this issue with expose schema using BizTalk WCF publishing wizard?
After changing web.config file as below
</system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Getting different error and trace as below:
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.BizTalk.Interop.SSOClient, Version=9.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
Microsoft.BizTalk.Adapter.Wcf.Runtime.BtsServiceHostBase.ConfigureClientCredentials() +0
Microsoft.BizTalk.Adapter.Wcf.Runtime.BtsServiceHostBase.InitializeRuntime() +1173
Microsoft.BizTalk.Adapter.Wcf.Runtime.WebServiceHost`3.InitializeRuntime() +130
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +63
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +563
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +135
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +654
[ServiceActivationException: The service '/OrderProcessingService/OrderProcessingService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'Microsoft.BizTalk.Interop.SSOClient, Version=9.0.1000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +15778592
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +15698937
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +265
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +227
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
That first error basically means that you have tried publishing multiple different protocols in the same App Pool. You need to have separate IIS App pools for the different protocols.
Also make sure that the Application Pool is running with the Isolated Host user.

Exposing wcf service in BizTalk 2010

I have ran into this issue the past few weeks ago and I still can not figure out why.
I have a BizTalk orchestration that receives a BizTalk message, processes it and eventually writes it to a file. For simplicity sake, let say, our goal is to take the message (which is actually a survey) and save it to a folder as is. I have created a public receive port to catch the msg and a send port to write the result out to disk.
I have successfully deployed the project and have successfully published it to IIS. I was able to see the WCF service in IIS and have set it to use Framework 4.0. I have set up all the relevant receive and send ports and have started the application successfully from BizTalk management console. (The receive location was automatically created when I published the wcf service, the send location is a type FILE located in a folder in the computer)
From DefaultSite in IIS, I could see my WCF. However, when I tried http://localhost/TestSurvey/TestSurvey_Orchestration_1_getSurveyPort.svc,
I got the following error:
Server Error in '/TestSurvey' Application.
--------------------------------------------------------------------------------
Login failed for user 'Domain\ComputerName$'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'ACAD1\DENBIZDEV$'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Login failed for user 'Domain\ComputeName$'.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
Microsoft.BizTalk.TransportProxy.Interop.IBTTransportProxy.RegisterIsolatedReceiver(String url, IBTTransportConfig callback) +0
Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfIsolatedReceiver`2.RegisterIsolatedReceiver(Uri uri) +1028
Microsoft.BizTalk.Adapter.Wcf.Runtime.WebServiceHostFactory`3.CreateServiceHost(String constructorString, Uri[] baseAddresses) +363
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/TestSurvey/TestSurvey_Orchestration_1_getSurveyPort.svc' cannot be activated due to an exception during compilation. The exception message is: Exception has been thrown by the target of an invocation..]
System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
My question is: what is it that BizTalk was trying to login? Domain\ComputerName$ is definitely not a user. I have not tried to access any database from the orchestration. I believe my IIS was set up correctly as I have created a quick and dirty wcf service test from VS2010 and published it to my IIS, then have successfully created a simple client to consume the wcf service test. I did not encounter the same issue when I created the wcf service test directly.
Any help or hint is highly appreciated!
EDIT
I managed to fix this: it was not the web config as it was created by BizTalk. I had to create a special app pool and tied my application to using it. In the app pool I have to use the custom credential that BizTalk is using. Using the built in credentials caused the issue I experienced. My rookie error! Once BizTalk login credential was used, everything went smoothly.
The database which is throwing the SQL exception is one of the BizTalk databases, probably the management or SSO DB.
The error is almost certainly being caused by the setup of IIS, whether the app pool identity or the web site security settings.
What is hapenning is that when you call the service for the first time IIS is compiling your service, and to do this it obviously needs access to one of the BizTalk databases, but this call is not authenticated for some reason.
This could be because the app pool user must be a member of the BizTalk Isolated Host Users group (which may be called something different depending on how BizTalk was set up.

No compatible TransportManager error

Answer
It was a configuration problem.
We had two services in the application. Prior to the problem, both services had explicit binding configuration that matched and worked well. One service was going to be removed, so the dev remmed out the explicit binding configuration, forgetting that .NET 4.0 provides default (and different) bindings.
Whichever service was hit first, its settings would not be incompatible with any other settings (since it was first) and would be fine. The service that was loaded subsequently would have different binding settings and be refused by the TransportManager.
The apparent intermittency was due to us only focusing on the one remaining service, thinking the other service was no longer in the picture. A monitoring utility was still hitting the removed service and would get in sometimes before we could reload the other service after a configuration change.
Original Question
We're getting an intermittent error when first starting up a service in IIS. If I make a whitespace change to any of the configs and reload, then about 50% of the time the service will come up fine. Once it's up, it's good to go. But the next time we deploy to this box, we start the russian roulette all over again.
We've looked over other forum posts on the same error and so far have not been able to come up with a definite fix. It took us a while to realize that none of the configuration changes we were trying were actually influencing the problem since merely a whitespace change is enough to get it to start afresh and get it to work part of the time. Seems there's some sort of race condition internally with the TransportManagerTable, perhaps it's empty when the service fails to come up? Not sure, trying to get some tracing or something to give us better info on what's in the TransportManagerTable instance.
There is no compatible TransportManager found for URI 'net.tcp://box:10101/DEV/AwesomeService.svc'. This may be because that you have used an absolute address which points outside of the virtual application, or the binding settings of the endpoint do not match those that have been set by other services or endpoints. Note that all bindings for the same protocol should have same settings in the same application.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: There is no compatible TransportManager found for URI 'net.tcp://box:10101/DEV/AwesomeService.svc'. This may be because that you have used an absolute address which points outside of the virtual application, or the binding settings of the endpoint do not match those that have been set by other services or endpoints. Note that all bindings for the same protocol should have same settings in the same application.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: There is no compatible TransportManager
found for URI 'net.tcp://box:10101/DEV/AwesomeService.svc'. This may
be because that you have used an absolute address which points outside
of the virtual application, or the binding settings of the endpoint do
not match those that have been set by other services or endpoints.
Note that all bindings for the same protocol should have same settings
in the same application.]
System.ServiceModel.Channels.TransportChannelListener.ThrowTransportManagersNotFound()
+8955459 System.ServiceModel.Channels.TransportChannelListener.SelectTransportManagers()
+16199511 System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback
selectTransportManagerCallback) +71
System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan
timeout) +182
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +789
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +375
[InvalidOperationException: The ChannelDispatcher at
'net.tcp://box:10101/DEV/AwesomeService.svc' with contract(s)
'"IAwesomeService", "ILoggingService"' is unable to open its
IChannelListener.]
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan
timeout) +16199205
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +789 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan
timeout) +126
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan
timeout) +789
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +287
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +1132
[ServiceActivationException: The service '/DEV/AwesomeService.svc'
cannot be activated due to an exception during compilation. The
exception message is: The ChannelDispatcher at
'net.tcp://box:10101/DEV/AwesomeService.svc' with contract(s)
'"IAwesomeService", "ILoggingService"' is unable to open its
IChannelListener..] System.Runtime.AsyncResult.End(IAsyncResult
result) +890624
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +180062
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult
ar) +107
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.1
Edited the configuration to set the Address Empty and the error was fixed.
To add a little bit more instruction, the issue is most likely in the Web.Config file of your service. In the node, make sure that your Endpoint Address is an empty string -or- make sure that your Endpoint Address URL points to the exact location of your service, as you specified in IIS.
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyServiceBinding" contract="MySolution.IMyService"/>

Silverlight3.0 + WCF Service hosting issues: Communication Exception

I am working with silverlight3 with WCF service for a while.. I have developed and hosted my application into client mechine. It was working good. Then i need to do some modifications in my application, so I have added new functions in to my .svc file(i.e in to the wcf service). I have updated the servicereference successfully. When i re published and access it, it throws the error in a particulare method which i newly added.. But the other functions and data retreival are working good.. The newly added functions of the wcf services throws the communication error.
This is the function which i used to bind the combobox by the data retrieved from the wcf service..
Actual Error:
System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClass5.b_4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c_DisplayClass2.b_0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase1.ChannelBase1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.Service1ClientChannel.EndUsergetBasedWorkgroup(IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.ServiceReference1_IService1_EndUsergetBasedWorkgroup(IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.OnEndUsergetBasedWorkgroup(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at foundproject.ServiceReference1.UsergetBasedWorkgroupCompletedEventArgs.get_Result()
at foundproject.UserMaster.BindUsers(Object sender, UsergetBasedWorkgroupCompletedEventArgs e)
Please Please help me to solve it out..
It will be a great help for me..
Thanks
Lakshmi.A
All methods in webservice are implemented using Interfaces, if you have added your function in Class file make sure its implemented by its interface-template/interface-method signature.
You have not changed the namespace of the newly added method.
the access modifier is public.
Try running your webservice file "svc" from IIS Management Console using Browse by Right clicking on "svc" file. it must show a default web service UI that we normally expect.
Debug your web service, and see if it hits the break point over your newly added method.
I'm sure by following these simple steps you will solve your problem.

WCF: referencing a service from script manager issue

I'm working from a project on localhost:2971 and in the master page i want to include an asp:ScriptReference to a wcf service i am hosting in IIS at localhost:5152
<Services>
<asp:ServiceReference InlineScript="false" Path="http://localhost:5152/CostService.svc" />
</Services>
then i attempt to call:
var service = new SandwichServices.CostService();
service.CostOfSandwiches(5, onSuccess);
on a page that inherits from the master page.
however, in the firefox error console i get the following:
Error: no element found
Source File: http://localhost:2971/CostService.svc/CostOfSandwiches
Line: 1
So why is the source file pointing to 2971?
the service works fine on the sample page i created on 2152.
Anyone know whats up?
Any help would be much appreciated!
<!--
[EndpointNotFoundException]: The service '/CostService.svc' does not exist.
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
[HttpException]: The service '/CostService.svc' does not exist.
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext)
at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
I would think you are developing using Cassini (Web Server Inside VS). You need two instances of Cassini to have access to the 2 ports you are talking about. If it was IIS the portnumber is not required.