Error while adding service reference for a wcf service - asp.net

I am getting an error when i try to add a service reference of a WCF service. Error details is below. My web service is hosted on a different server and my client is on different server. When i run the service directly from IE i can see the service but adding it in .net web application i get error. Please advise
There was an error downloading
'http://193.11.33.66/coverscanservice/DownloadCoverScan.svc'.
The request failed with HTTP status
503: Service Unavailable. Metadata
contains a reference that cannot be
resolved:
'http://193.11.33.66/coverscanservice/DownloadCoverScan.svc'.
The HTTP service located at
http://193.11.33.66/coverscanservice/DownloadCoverScan.svc
is too busy. The remote server
returned an error: (503) Server
Unavailable. If the service is defined
in the current solution, try building
the solution and adding the service
reference again.

If you open up the properties of the application pool assigned to this service, you can turn off the rapid fail protection for this pool with the checkbox. This may alleviate the 503 error but it won't diagnose your true problem.
You'll need to install the windows debugging tools and/or Debug Diagnostics for IIS in order to find the true source of the problem. Something is causing your w3wp.exe process to crash repeatedly, and it can't recover. Also, check your event log for items related to the w3wp.exe stopping unexpectedly. There may be helpful information there.

In ASP .NET Web Application after Adding the WCF Webservice reference .Right click on that reference check the Configure Service Reference change setting like in collection type set "System.collection.ObjectModel.ObservableCollection".Also change Reuse types in specified referenced assemblies set "Microsoft.Web.Infrastructure" .
After that Build the project Call the Service Methods used it and Run it.

Related

Application Initialization IIS - Log Files

I have configured the Application Initialization for a Web App running on Azure, the reason for that is to improve the "warm up", because I have some issues with Scale-out, the instance is not ready for the connection then I got some servers errors.
There is a good doc from Microsoft about that:
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-application-initialization
I am not sure how to check if Application Initialization is working.
Are there any logs that I can check?
IIS doesn’t provide separate log files for each modules and function, but for each website. So application initialization for a web to improve the “warm up”, can be checked by some function.
Advanced Logging is helpful and analyze the log file of the website which applied application initialization module. You can get it from here
Fail Request Tracing also can help you to trace request when you try to access the website to test whether the initialization is successful, especially using url rewrite with application initialization. Enable fail request tracing from here.

Exceptions are not shown in Request details but under Server Exceptions in Application Insights

When an exception occurs during execution of a Web.Api controller method in our system, the request is sent to Application Insights as a failure and we send the exception to Application Insights with telemetry.TrackException(actionExecutedContext.Exception);
Behavior:
request is shown as a failure with URL and some other data in the details
exception is shown under Server exceptions with the stack trace shown in the details.
However, when looking at the details of a failed request (due to a server exception), the Exception part does not show the correlated exception - just the default Learn how to track exceptions for failed requests.
When looking at what is sent to Application Insights inside Visual Studio 2017, I see that the exception and request are correlated (same Operation Id).
But it seams that this gets lost on the way to the detail page.
We use ASP.NET WebApi with OWIN, default Application Insights installation (of nuget packages) and applicationinsights-owinextensions (including the steps described there to setup the OWIN extension).
I think How to link exceptions to requests in Application Insights on Azure? does not apply because the data is shown as correlated in the Visual Studio AppInsights Viewer and when clicking Show telemetry for: this operation inside the details view of the exception inside AppInsights.
Maybe related:
Application Insights shows 2 requests for a failure. The first one shows the HTTP Method (e.g. GET) the second one misses the HTTP Method and has a duration that is slightly longer.
Thanks for hints :-)
As you are using applicationinsights-owinextensions, I checked the code for OperationIdTelemetryInitializer that is used to initialize operation id. I believe the reason you're not seeing telemetry linked correctly on detail blades is that this code is not setting operation.parentId field. To verify whether this is correct you can examine the payload sent to check whether parent.id field is set. The initializer that we are shipping in the officially supported .NET SDK sets operation.id, as well as operation.parentId.
So my recommendation is, once you confirm, that parentId is indeed not set, would be to to either fix the OperationIdTelemetryInitializer used in owin-extensions so it starts setting parentId, or replace it in ApplicationInsights.config with your custom one. The latter approach would make it easy to confirm this theory.
The solution was to remove the Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer from the application insights config file.
This initializer gets in the way of the initializer from applicationinsights-owinextensions nuget package.

WCF service - what could cause it to randomly shut-down?

In IIS, I have an ASP.net web application that makes many behind-the-scenes calls to an IIS-hosted WCF service.
I never had any issues during development. However, since deploying to a few test servers at work, our tester was reporting that some of the calls were seemingly randomly failing. I verified that indeed, some of those behind the scenes webapp->service calls were failing with a "(417) Expectation Failed". Hitting the back-button and attempting the action again always worked.
A common solution I kept seeing online was https://stackoverflow.com/a/7358457/1669011
After adding that to my web config, the error continued to happen, but instead of returning a 417, would end up returning the results of my web.config's applicationInitialization remapManagedRequestsTo page.
I feel like the web.config fix I mentioned above has just allowed my web application to accept the full body of the response rather than failing when it realised it wasn't the wcf response it was expecting.
So if random services in WCF are returning the results of remapped requests that occur during Application Initialization, does that indicate that my WCF services in IIS are constantly totally shutting down?
What might cause my WCF service to randomly be in a state of "application initialization"? I'm hoping this is just a server issue and nothing to do with my application, as this has come out of nowhere and is risking an upcoming deploy.
Thanks for any assistance
My guess would be time (or very serious exceptions).
Specifically, if the server hosting the WCF service is not being hit often enough, it will shut down the application. Follow the instructions here to ensure the WCF site is not being unloaded: How to keep a WCF site online?.
If it's exceptions, you have not provided enough information to diagnose the issue.

Web service call failing with 5xx type errors

We've inherited a .asmx web service without source code (my favourite).
We've run tests (calling it from a console app with fiddler attached) both internally and externally and it runs clean every time - as it does for the vast majority of our clients.
However, one user is reporting 5xx type errors. We've tried all the usuals (event viewer and IIS logs) but they're all clean. We can't get it to fail at all.
What further options do we have?
Can the clients replicate the error at will?
The error is most likely data related. Have you tested it with the same data that your client is to produce the error.
The error may also be at the client's end during serialization/deserialization of the call in their auto-generated asmx wrapper.
Has there been a change to the WSDL?
Things like ELMAH are great for logging all unhanded exceptions.
add logging to web config, log everything.
decompile the webservice and find the reason.

How can I find out more diagnostic information from a failed web service call?

When calling an asp.net web service from a windows mobile device project, I am catching an exception ( WebException ) and the response inside that seems to be "BadRequest".
This is occurring on a live system but not locally in development. But they both have the same build....
When we point our development code at the live web service we get the BadRequest error again. Is there any way I can get more information about this error?
We use Elmah for logging and can confirm no exceptions are being thrown in the web service itself, in fact, it isn't even getting invoked!
Bad Request is a generic error which means the server didn't even bother looking much at the request from the client because it was significantly malformed in some way (service receive buffer lengths exceeded, etc.).
Try to send the server something simpler from the client until it works and/or gives a different (more precise) error.
Unfortunately, server exception handling or viewing traffic on the wire with a tool like Fiddler is probably not going to be helpful in this scenario.
It would help to know which version of web services this is (ASP.NET 2.0, WCF, etc.).

Resources