へのHTTP応答の受信中にエラーが発生しましたdownvoteの前に、このような質問が重複していることがわかりましたが、試してみて解決策を見つけることに成功しませんでしたそれら。私は何かを逃したかもしれませんが、まだWCFには比較的新しいので、いくつかは私の頭を少し上回ります。WCF - http:// xxxxx/Service/
私は私のWCFサービスでこのコールを作っています:
public User GetStudentRecord(string userName)
{
try
{
return new DashboardFacade().GetStudentRecord(userName);
}
catch (Exception ex)
{
ServiceFault fault = new ServiceFault();
fault.Operation = "GetStudentRecord";
fault.Reason = "Who knows...";
fault.Message = ex.Message;
throw new FaultException<ServiceFault>(fault, fault.Message, new FaultCode(fault.Reason), fault.Operation);
}
}
DashboardFacade()GetStudentRecord(..)はこのように定義されています。
public User GetStudentRecord(string userName)
{
User user = ctx.Users.Where(x => x.ADUserName == userName).SingleOrDefault();
return user;
}
CTXは私のDbContextです。 Entity Framework Code Firstを使用しています。 Userオブジェクトは、次のようになります。
public class User
{
public User()
{
//UserDetails = new UserDetail();
}
[Key]
public Guid MasterKey { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string ADUserName { get; set; }
public string UserType { get; set; }
public virtual UserDetail UserDetails { get; set; }
public Nullable<DateTime> LastModifiedDate { get; set; }
}
そして最後に、あなたはおそらくWCFアプリケーションにweb.configファイルを参照する必要があります。
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="NotMyDBContextDB" connectionString="[omitted]" providerName="System.Data.SqlClient"/>
<add name="ApplicationContext" connectionString="Data Source=.;Initial Catalog=MyApp;Integrated Security=True;Pooling=False" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
誰も私が間違ってここつもりどこに私を指すことができますか?あなたが返されたユーザーオブジェクトのいくつかのフィールドにアクセスしようとすると、
An error occurred while receiving the HTTP response to http://localhost:5843/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Inner Exception:
An existing connection was forcibly closed by the remote host
エラーはどこに投げられますか?デバッガでサービスを実行します。 – dthorpe
エラーメッセージと内部例外メッセージが追加されました。私はデバッガでそれを実行することができ、それは私が上に持っているすべてのコードをステップ実行することができます。実際のサービスでGetStudentRecord()を呼び出すと、数秒後にエラーが発生します。 – ledgeJumper