[질문 원글: http://mblog.devpia.com/link/?no=2114383]
WCF를 구축하는데요...클라이언트는 다음과 같이 구현했습니다.
public ref class ClientComp : IClientComp
{
// TODO: 여기에 이 클래스에 대한 메서드를 추가합니다.
public :
virtual void Connect() {
try
{
WSHttpBinding^ binding = gcnew WSHttpBinding();
String^ url = "http://localhost:8088/WebService";
EndpointAddress^ address = gcnew EndpointAddress(url);
ChannelFactory<IWebService^>^ channelFactory = gcnew ChannelFactory<IWebService^>(binding, address);
m_channel = channelFactory->CreateChannel();
m_channel->Connect(); //여기까지는 잘됩니다.
}
catch(Exception^ e){
Console::WriteLine(e->Message);
}
}
virtual void Disconnect() {
if (m_channel != nullptr) {
m_channel->Disconnect();
((IChannel^)m_channel)->Close();
}
}
virtual void Insert(String^ Id,String^ passwd, String^ Name){
Person^ p = gcnew Person();
p->ID = Id;
p->Passwd = passwd;
p->Name = Name;
m_channel->InsertMember(p); //이 함수도 호출이 되어 잘 실행됩니다.
}
virtual void Update(String^ Id,String^ passwd, String^ Name){
Person^ p = gcnew Person();
p->ID = Id;
p->Passwd = passwd;
p->Name = Name;
m_channel->UpdateMember(p);
}
virtual void Delete(String^ Id,String^ passwd, String^ Name){
Person^ p = gcnew Person();
p->ID = Id;
p->Passwd = passwd;
p->Name = Name;
m_channel->DeleteMember(p);
}
virtual ArrayList^ Select(String^ Id,String^ passwd, String^ Name){
Person^ p = gcnew Person();
if(Id == nullptr ) {
p = nullptr;
}
else {
p->ID = Id;
p->Passwd = passwd;
p->Name = Name;
}
return m_channel->SelectMember(p); //여기서 예외가 발생하는것 같습니다---(1).
}
private :
IWebService^ m_channel; // IWebService는 엔드포인트 인터페이스 입니다.
};
}
서버는 다음 어플이 구동합니다.
#include "stdafx.h"
using namespace System;
using namespace System::ServiceModel;
using namespace WebService;
int main(array<System::String ^> ^args)
{
WSHttpBinding^ binding = gcnew WSHttpBinding();
Uri^ baseAddress = gcnew Uri("http://localhost:8088/WebService");
ServiceHost^ servicehost = gcnew ServiceHost(WebServiceImple::typeid, baseAddress);
servicehost->AddServiceEndpoint(IWebService::typeid, binding, baseAddress);
servicehost->Open();
Console::WriteLine("The service is running...");
Console::ReadLine();
servicehost->Close();
delete servicehost;
return 0;
}
엔드포인트 인터페이스는 다음과 같습니다.
namespace WebService {
[ServiceContract]
public interface class IWebService {
[OperationContract]
void Connect();
[OperationContract]
void Disconnect();
....
그런데 (1)에서 System.ServiceModel.CommunicationException 예외가 발생합니다. 메세지는 아래와 같습니다.
처리되지 않은 'System.ServiceModel.CommunicationException' 형식의 예외가 mscorlib.dll에서 발생했습니다.
추가 정보: http://localhost:8088/WebService에 대한 HTTP 응답을 수신하는 동안 오류가 발생했습니다. 이것은 서비스 끝점 바인딩에서 HTTP 프로토콜을 사용하지 않기 때문일 수 있습니다. 또한 서비스 종료로 인해 서버가 HTTP 요청 컨텍스트를 중단하는 중이기 때문일 수 있습니다.
바인딩을 바꿔주어야 할까요? 이유가 뭔지 모르겠네요..쩝 -_-
고수님의 도움을 청합니다. 꾸벅(_ _)
좋은 하루 되시구요..^^