我在部署到预生产环境时遇到了WCF问题。它在本地工作正常。 我得到的AJAX消息是出现了一个分析错误,但我无法在preprod服务器上进行任何跟踪日志记录,但同样,日志在我的本地(具有相同的webconfig设置)上正常工作。
Traces.svlog在preprod上记录任何内容的唯一时间是卸载应用程序域时。在我的本地,我可以抛出故意的例外,这将在日志中得到。登录后无法访问WCF服务
如果我登录,我无法导航到服务的路径,而是引发异常(请参阅下文)。但是,如果我不登录,我可以访问服务页面并单击进入wsdl,并查看方法等。我知道登录后发生了什么问题。
例外:
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)
我们在preprod环境中运行IIS6。
起初,我注意到在IISManager-> AppplicationProperies-> HomeDirectory-> Configuration中没有svc扩展名。然后我手动添加它。
在此之后,而且由于我曾在其他地方看,我也跑在正确的位置以下两个命令:
aspnet_regiis -i
ServiceModelReg.exe -i
再次,他们没有做任何修正这个错误。
我的主要困惑是,只要我没有登录,我可以输入URL并访问svc wsdl。从上面的错误消息可以看到,我们的webconfig使用模拟 - 不确定是否有任何影响。
我的服务目录结构是这样的
Application
->AppCode
...->People.vb
->DirA
...->DirB
......->Calling.aspx
->WebServices
...->People.svc
在Calling.aspx我的Ajax调用如下所示:
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
}
});
的SVC如下所示:
而且我的Vb看起来像下面这样:
<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
正如你所看到的,我并没有打算为合同创建一个单独的接口 - 我只是把它放在具体的类。
(我也匿名了代码和ip等)。
我Webconfig如下所示(减去其他事情的其他应用程序中有大量的群众。
<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>
我变成那种这里难倒了,我很新的任何类型的Web服务但是,我希望我提供足够的信息,以便其他人可以或许看到的问题。
任何帮助将非常感激。
感谢。