아래 클래스가 있지만 SayHello 만 사용할 수 있습니다. 그 이유를 아는 사람 있니?WCF의 데이터 계약 및 순환 참조
public class Service1 : IService1
{
public Department GetDepartment()
{
Department d1 = new Department() { DepartmentName = "dep1" };
d1.employees = new List<Employee>() {
new Employee() {
username="user1",
department=d1
},
new Employee() {
username="user2",
department=d1
}
};
return d1;
}
public string SayHello(string username)
{
return "Hello " + username + "!";
}
}
[DataContract]
public class Department
{
[DataMember]
public string DepartmentName { get; set; }
[DataMember]
public List<Employee> employees { get; set; }
}
[DataContract]
public class Employee
{
[DataMember]
public string username { set; get; }
[DataMember]
public Department department { get; set; }
}
는 sayHello가 있었다 잘 작동하지만 GetDepartment은 다음 오류와 함께 실패 : http://localhost:8080/에 HTTP 응답을받는 동안 오류가 발생했습니다 *
. 이것은 HTTP 프로토콜을 사용하지 않는 서비스 엔드 포인트 바인딩 때문일 수 있습니다. 이것은 HTTP 요청 컨텍스트가 서버에 의해 중단 되었기 때문일 수도 있습니다 (서비스 종료로 인한 것일 수도 있음). 자세한 내용은 서버 로그를 참조하십시오. 서버 스택 추적 :
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IService1.GetDepartment()
at Service1Client.GetDepartment()
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)*
로 시작하기를, 당신은 디버깅 했습니까? –
WCF 추적 기능을 켜고 문제의 징후를 알려주십시오. http://weblogs.asp.net/seaniannuzzi/wcf-diagnostics-implementation-in-5-easy-steps –
WCF 바인딩 게시 ... –