I'm having a WCF issue when deploying to our pre-production environment. It is working fine locally.
The AJAX message I'm getting is that there has been a parse error, but I am unable to get any trace logging going on the preprod server, but again, logging is working fine on my local (with same webconfig settings).
The only time the Traces.svlog will record anything on preprod is when the app domain is unloaded. On my local, I can throw deliberate exceptions and this will get picked up in the log.
If I am logged in, I am unable to navigate to path of the service, instead an exception is thrown (see below). However, if I don't login, I can access the service page and click into the wsdl, and see the methods etc. I have know idea what is going wrong after login.
Exception:
Process information:
Process ID: 4796
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: InvalidCastException
Exception message: Unable to cast object of type
System.ServiceModel.Activation.HttpHandler' to type 'System.Web.UI.Page'.
Request information:
Request URL: http://100.100.100.104/Application/Webservices/People.svc/GetAllActive
Request path: /Application/Webservices/People.svc/GetAllActive
User host address: 102.24.1.152
User:
Is authenticated: False
Authentication Type:
Thread account name: domainA\userB
Thread information:
Thread ID: 7
Thread account name: domainA\userB
Is impersonating: True
Stack trace: at ASP.global_asax.Application_PreRequestHandlerExecute
(Object sender, EventArgs e)
at
System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
We are running IIS6 on the preprod environment.
At first, I noticed that the svc extension was not there in IISManager -> AppplicationProperies->HomeDirectory->Configuration. I then added it manually.
Following this, and due to what I had read elsewhere, I also ran the following two commands from the correct locations:
aspnet_regiis -i
ServiceModelReg.exe -i
Again, they did nothing to fix the error.
My main confusion is that I can type into URL and access the svc wsdl as long as I'm not logged in. As you can see from error message above, our webconfig is using impersonate - not sure if this has any effect.
My service directory struct is such
Application
->AppCode
...->People.vb
->DirA
...->DirB
......->Calling.aspx
->WebServices
...->People.svc
My ajax call in Calling.aspx looks like the following:
jQuery_1_8_3(document).ready(function() {
jQuery_1_8_3.ajaxSetup({
data: "{}",
dataType: "json",
type: "POST",
contentType: "application/json",
converters: {
"json jsond": function(msg) {
return msg.hasOwnProperty('d') ? msg.d : msg;
}
}
});
jQuery_1_8_3.ajax({
url: "../../Webservices/People.svc/GetAllActive",
success: function(resdata) {
//etc
}
});
The svc looks like the following:
And My Vb looks like the following:
<ServiceContract(Namespace:="people")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class People
<CLSCompliant(False)> _
<OperationContract()> _
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Wrapped, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)> _
Public Function GetAllActive() As PersonDetailDataContract()
Dim service As New RepositoryService()
Dim personList As IList(Of Interfaces.ModelInterfaces.IPersonDetail)
personList = service.GetAllPersonDetails()
Dim contractList As New ArrayList()
For Each
//Populate contractlist, etc
Next
Dim array() As PersonDetailDataContract
array = contractList.Cast(Of PersonDetailDataContract)().ToArray()
Return array
End Function
End Class
As you can see, I haven't bothered to create a separate interface for the contract - I've just put it on the concrete class.
(I've also anonymised the code and ip's, etc).
My Webconfig looks as follows (minus the massive multitude of others things for other apps in there.
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "C:\svclogs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="true"
logMalformedMessages="true"
logEntireMessage="true"
maxSizeOfMessageToLog="65535000" maxMessagesToLog="500" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="PeopleTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="json">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="People" behaviorConfiguration="PeopleTypeBehaviors">
<endpoint address=""
behaviorConfiguration="json"
binding="webHttpBinding"
contract="People" />
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
I'm becoming kind of stumped here, and I'm very new to WebServices of any kind. However, I hope I've provided enough information so that others can perhaps see the issue.
Any help will be much appreciated.
Thanks.