나는 간단한 웹 서비스를 실행하고 있으며 콘솔 애플리케이션 클라이언트가 서비스를 사용하고있다. 이 문제가 생겨서이 커뮤니티에서 멋진 사람들이 도움을 받았다.WCF 웹 서비스 사용하기
나는 루프에서 클라이언트의 서비스를 호출하려는 경우 작동하지 않는 또 다른 문제가 있습니다. 그것은 처음으로 작동하고 그 후에 다만 기다리는 것을 계속한다. 왜 이런 일이 일어나고 어떻게 해결할 수 있습니까?
코드 :namespace WebService
{
[ServiceContract]
public interface IService
{
[OperationContract(Name="Result")]
[WebGet(UriTemplate = "/")]
Stream Result();
}
public class Service:IService
{
public Stream Result()
{
// read a file from the server and return it as stream
}
}
}
The client:
namespace WebServiceClient
{
[ServiceContract]
public interface IService
{
[OperationContract(Name="Result")]
[WebGet(UriTemplate = "/")]
Stream Result();
}
}
static void Main()
{
Console.WriteLine("Press enter when the service is available");
Console.ReadLine();
// creating factory
HttpChunkingBinding binding = new HttpChunkingBinding();
binding.MaxReceivedMessageSize = 0x7fffffffL;
ChannelFactory<WebServiceClient.IService> factory = new ChannelFactory<WebServiceClient.IService>
(binding, new EndpointAddress("http://localhost/WebService/Service"));
WebServiceClient.IService service = factory.CreateChannel();
for(int i = 0; i < 10; i++)
{
Stream s = service.Result();
// write this stream to a file and close the stream
}
//Closing our channel.
((IClientChannel)service).Close();
}
감사합니다,
포스트 코드 및 예외 메시지 – Juliet
일부 코드를 게시 할 수 있습니까? 또한 웹 서비스를 디버깅하는 좋은 방법은 Fiddler를 사용하여 HTTP 트래픽을 감시하는 것입니다. – Alan
어떤 기술을 사용하고 있습니까? – tster