私は WCF サービスを持っています。このサービスでは、多くのプロパティを持つクラスを返します。その一部はクラス自体であり、少し複雑ですが、それほど大きくはありません。同じプロジェクトで別の WCF サービスを使用して同様のことを行ったところ、すべて正常に機能しました。しかし、これを使用すると、このエラーが発生しました。
[System.ServiceModel.CommunicationException] {"An error occurred while receiving the HTTP response to http://xxx/Service.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."} System.ServiceModel.CommunicationException
内部例外は
[System.Net.WebException] {"The underlying connection was closed: An unexpected error occurred on a receive."} System.Net.WebException
その内部例外は言う
[System.IO.IOException] {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."} System.IO.IOException
その内部例外は言う
[System.Net.Sockets.SocketException] {"An existing connection was forcibly closed by the remote host"} System.Net.Sockets.SocketException
だから、これが私が試したことです。.svc ファイルにエラーがあるか、.config ファイルの構成にエラーがあるのではないかと思いましたが、私が見る限り、そうではありません。次に、単純な型をサーバーからクライアントに送信できるかどうかを試してみるべきだと思いました。したがって、7 を返す GetInt() というメソッドを作成しました。これをクライアントで呼び出したところ、問題なく動作しました。したがって、サポートされていないのは、サーバーから送り返すデータだと思います。私が言ったように、同じプロジェクトで以前に複雑な型を送信したことがあるため(昨日だけ)、すべてが機能したため、理由がわかりません。とにかく、これが私が送っている私のクラスです。おそらく、誰かがサポートされていない可能性があることを指摘できます。あるいは、他に何が原因なのかを誰かが知っているかもしれません。
public class Hotels
{
public string Language { get; set; }
public string Datum { get; set; }
public List<HotelListing> HotelListing { get; set; }
}
public class HotelListing
{
public long Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
public string Category { get; set; }
public List<PhoneNumber> PhoneNumbers { get; set; }
public Address Address { get; set; }
public Content Content { get; set; }
}
public class Content
{
public Description Description { get; set; }
public List<Review> Reviews { get; set; }
public Image Image { get; set; }
public AtrttributeData AtrttributeData { get; set; }
}
public class AtrttributeData
{
public string Link { get; set; }
public string Title { get; set; }
public NameValueCollection Attributes { get; set; }
}
public class Image
{
public string Type { get; set; }
public string ImageURL { get; set; }
public string HotelURL { get; set; }
}
public class Review
{
public string Type { get; set; }
public string Link { get; set; }
public string Author { get; set; }
public string Body { get; set; }
public NameValueCollection Ratings { get; set; }
}
public class Description
{
public string Link { get; set; }
public string Title { get; set; }
public string Body { get; set; }
}
public class Address
{
public string Format { get; set; }
public string Addr1 { get; set; }
public string Addr2 { get; set; }
public string City { get; set; }
public string PostCode { get; set; }
}
public class PhoneNumber
{
public string Type { get; set; }
public string Number { get; set; }
}
問題のメソッドはこれです
[OperationContract]
Hotels GetHotels();
どんな助けでも大歓迎です。
これが私の構成セクションです
<binding name="BasicHttpBinding_ITablet" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<snip>
<endpoint address="http://xxx/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITablet"
contract="SupplierInterfaceTabletService.ITablet" name="BasicHttpBinding_ITablet" />
ありがとう、
サチン