実稼働前の環境に展開するときにWCFの問題が発生します。ローカルで正常に動作しています。私が受け取っているAJAXメッセージは、解析エラーが発生したというものですが、preprodサーバーでトレースログを取得できませんが、ローカルでログが正常に機能しています(同じwebconfig設定で)。
Traces.svlogがpreprodに何かを記録するのは、アプリドメインがアンロードされたときだけです。私のローカルでは、意図的な例外をスローすることができ、これはログに記録されます。
ログインしている場合、サービスのパスに移動できず、代わりに例外がスローされます(以下を参照)。ただし、ログインしない場合は、サービスページにアクセスして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を実行しています。
最初、私はsvc拡張機能がIISManager-> AppplicationProperies->HomeDirectory->Configurationにないことに気づきました。次に、手動で追加しました。
これに続いて、そして私が他の場所で読んだことのために、私はまた正しい場所から次の2つのコマンドを実行しました:
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>
私はここでちょっと困惑し始めています、そして私はどんな種類のWebServicesにも非常に慣れていません。ただし、他の人が問題を確認できるように、十分な情報を提供したことを願っています。
どんな助けでも大歓迎です。
ありがとう。