2016-03-27 20 views
1

私は私のモジュールのクラス(エンティティ)が続く(WCFを通じてエンティティを送信中)WCFテストクライアントエラーは、サービスを呼び出すために失敗しました

ようです list<Module>

を返すすべてのメソッドが1以外正常に動作サービスを持っています設定がされ

An error occurred while receiving the HTTP response to http://localhost:8888/ArchService/. 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. 

Server stack trace: 
    at 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 IArchService.GetAllModules() 
    at ArchServiceClient.GetAllModules() 

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) 

として

[DataContract(IsReference = true)] //prevents Infinite loop 
[KnownType(typeof(SubModule))] 
public class ModuleMst 
{ 
    public ModuleMst() 
    { } 

    [Key] 
    [DataMember] 
    public int moduleid { get; set; } 

    [StringLength(100)] 
    [DataMember] 
    public string modulename { get; set; } 

    [StringLength(1)] 
    [DataMember] 
    public string status { get; set; } 

    [DataMember] 
    public string crby { get; set; } 

    [DataMember] 
    public DateTime crdt { get; set; } 

    [DataMember] 
    public string modby { get; set; } 

    [DataMember] 
    public DateTime moddt { get; set; } 

    //[DataMember] 
    public virtual List<SubModule> SubModules { get; set; } 

} 

例外WcfTestClientを示す

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="LargeSettingsWS" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"> 
      <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="None" /> 
     </binding> 
     </wsHttpBinding> 
     <netTcpBinding> 
     <binding name="LargeSettingsTcp" maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="524288"> 
      <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport" > 
      <transport clientCredentialType="Windows" /> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
     <netNamedPipeBinding> 
     <binding name="LargeSettingsPipe" maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="524288"> 
      <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport" /> 
     </binding> 
     </netNamedPipeBinding> 
    </bindings> 
    <services> 
     <service name="AppService.ArchService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:8808/ArchService" /> 
      <add baseAddress="net.pipe://localhost/ArchService/" /> 
      <add baseAddress="http://localhost:8888/ArchService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="LargeSettingsWS" contract="AppService.IArchService"> 

      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="LargeSettingsTcp" name="netTcpEndPoint" contract="AppService.IArchService" listenUriMode="Explicit"> 
      <identity> 
      <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" /> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="NetSvc" binding="netNamedPipeBinding" bindingConfiguration="LargeSettingsPipe" name="netPipeEndPoint" contract="AppService.IArchService" /> 

     <endpoint address="mex" binding="mexTcpBinding" name="MetadatEndpointTcp" contract="IMetadataExchange" endpointConfiguration="" /> 
     <endpoint address="mex" binding="mexNamedPipeBinding" name="MetadatEndpointNetPipe" contract="IMetadataExchange" /> 
     <endpoint address="mex" binding="mexHttpBinding" name="MetadatEndpointHttpDual" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 

      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" /> 

      <serviceDebug includeExceptionDetailInFaults="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

例外は非常に有用ではありません。

また、すべてのバインディングがこの特定の方法で失敗します。

私は何を欠場しましたか?

それは(Tは任意のエンティティとすることができる)のリストを返すようにしようとする任意の方法のように思えるがAn existing connection was forcibly closed by the remote host

EDIT

クライアント構成としてあるエラーで失敗EDIT続く

<bindings> 
    <netNamedPipeBinding> 
    <binding name="netPipeEndPoint" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600" > 
     <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="Transport" /> 
    </binding> 
    </netNamedPipeBinding> 
    <netTcpBinding> 
    <binding name="netTcpEndPoint" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"> 
     <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="Transport" /> 
    </binding> 
    </netTcpBinding> 

    <wsHttpBinding> 
    <binding name="WSHttpBinding_IArchService" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"> 
     <readerQuotas maxDepth="32" maxStringContentLength="100000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None" /> 
    </binding> 
    </wsHttpBinding> 
</bindings> 




<client> 
    <endpoint address="http://localhost:8888/ArchService/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IArchService" contract="ServiceReference.IArchService" name="WSHttpBinding_IArchService"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
    <endpoint address="net.tcp://localhost:8808/ArchService" binding="netTcpBinding" bindingConfiguration="netTcpEndPoint" contract="ServiceReference.IArchService" name="netTcpEndPoint"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
    <endpoint address="net.pipe://localhost/ArchService/NetSvc" binding="netNamedPipeBinding" bindingConfiguration="netPipeEndPoint" contract="ServiceReference.IArchService" name="netPipeEndPoint"> 
    <identity> 
     <userPrincipalName value="SYS1\deb" /> 
    </identity> 
    </endpoint> 
</client> 

編集3

他の関連するエンティティクラスが原因でエラーが発生しています。どうしてか分かりません。ここにある彼ら

[Table("SubModuleMst", Schema = "setp")] 
[DataContract(IsReference = true)] //prevents Infinite loop 
[KnownType(typeof(ModuleMst))] 
[KnownType(typeof(List<PageMst>))] 

public class SubModule 
{ 
    public SubModule() 
    { } 

    #region SubModule 

    [Key] 
    [DataMember] 
    public int submoduleid { get; set; } 
    [DataMember] 
    public int moduleid { get; set; } 
    [DataMember] 
    [StringLength(100)] 
    public string submodulename { get; set; } 
    [DataMember] 
    public int orderno { get; set; } 
    [DataMember] 
    [StringLength(1)] 
    public string status { get; set; } 
    [DataMember] 
    public string crby { get; set; } 
    [DataMember] 
    public DateTime crdt { get; set; } 
    [DataMember] 
    public string modby { get; set; } 
    [DataMember] 
    public DateTime moddt { get; set; } 
    #endregion 

    [DataMember] 
    public virtual ModuleMst Module { get; set; } 
    [DataMember] 
    public virtual List<PageMst> Pages { get; set; } 
} 

[Table("PageMst", Schema = "setp")] 
[DataContract(IsReference = true)] //prevents Infinite loop 
[KnownType(typeof(SubModule))] 
public class PageMst 
{ 
    public PageMst() 
    { } 

    #region PageMst 

    [Key] 
    [DataMember] 
    public int pageid { get; set; } 
    [DataMember] 
    [Required] 
    [ForeignKey("SubModule")] 
    public int submoduleid { get; set; } 
    [DataMember] 
    [StringLength(1000)] 
    [Required] 
    public string pagename { get; set; } 
    [DataMember] 
    [StringLength(1000)] 
    public string pageurl { get; set; } 
    [DataMember] 
    public int orderno { get; set; } 
    [DataMember] 
    [StringLength(1)] 
    public string menuitm { get; set; } 
    [DataMember] 
    public int rptparentid { get; set; } 
    [DataMember] 
    [StringLength(1)] 
    public string alertflag { get; set; } 
    [DataMember] 
    [StringLength(1)] 
    public string status { get; set; } 
    [DataMember] 
    public string crby { get; set; } 
    [DataMember] 
    public DateTime crdt { get; set; } 
    [DataMember] 
    public string modby { get; set; } 
    [DataMember] 
    public DateTime moddt { get; set; } 
    [DataMember] 
    [StringLength(200)] 
    public string paramids { get; set; } 
    [DataMember] 
    [StringLength(500)] 
    public string repurl { get; set; } 
    #endregion 

    [DataMember] 
    public virtual SubModule SubModule { get; set; } 
} 

EDIT 4

今、私はエラーがEFによって作成されたプロキシは、このMSDNの記事によると、このようなとしてシリアライズないですによるものであることが確認されています https://msdn.microsoft.com/en-us/library/ee705457(v=vs.100).aspxthis SO Article

+0

WCF/SOAPはリストに問題がありません。私はそれがDataContractの特定の部分にまで及ぶと考えています。可能であれば、サービス側例外の詳細を表示するには、サービスに接続することをお勧めします。 –

+0

@Glen Thomas面白いことは、私は同じ型のオブジェクトを返すことができるということです。このタイプのリストでのみ問題が発生します! – Deb

+0

例外の詳細を得ることができれば、これをもっと速く解決できます。 –

答えて

1

私の質問に誰も答えなかったので、私はそれが誰か他の人を助けることを望むように働かせるためにここに投稿しています。私は私です。

POCOプロキシタイプは、Windows Communication Foundation(WCF)as per this MSDN Articleによって直接シリアル化またはデシリアライズできないことが判明しました。

これは、EFがPOCOクラスと同じクラスではないエンティティトラッキングのPOCOの周りにWrapperを作成するため、既知のタイプのみをシリアル化できるため、WCFはシリアル化できないからです。

エンティティを作成するにはSerializableWCF次のいずれかを行う必要があります。

  1. コンフィグレーションDBContextでプロキシの作成を無効にします。(See this
  2. 使用.AsNoTracking()See this SO Post
  3. は、私は3番目のアプローチを使用し、私のサービス

(チュートリアルのためのMSDNの記事上記参照)ProxyDataContractResolverを使用してエンティティを返すあなたのサービスメソッドを飾るために属性を使用します最後にPOCOエンティティを返します。ウォークスルーの記事のコードは自己説明的なのでここには載っていません。

そして最後に、DTOがEFが考慮される限り最良の方法だと思います。

関連する問題