我在部署到預生產環境時遇到了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服務但是,我希望我提供足夠的信息,以便其他人可以或許看到的問題。
任何幫助將非常感激。
感謝。