The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

rakshi09@gmail.com (1) [Avatar] Offline
#1
i created web service using xml & function definition is in web services when i tried to access the service the exception was thrown.


#include "stdafx.h"

//interface class ISimpleService;
//interface class ISimpleServiceChannel;
ref class SimpleServiceClient;

using namespace System;
using namespace System::ServiceModel;
using namespace System::ServiceModel::Channels;


[ServiceContract]
interface class ISimpleService
{
[OperationContract]
String^ GetName(String^ request);

};
int main(array<System::String ^> ^args)
{
//Console::WriteLine(L"Hello World");
WSHttpBinding^ binding = gcnew WSHttpBinding();
//ISimpleService^ single;
Uri^ baseAddress = gcnew Uri("http://localhost:2110/TestWebService.Host/SimpleService.svc");
ServiceHost^ servicehost = gcnew ServiceHost(ISimpleService::typeid, baseAddress);
servicehost->AddServiceEndpoint(ISimpleService::typeid,binding,baseAddress);
servicehost->Open();
Console::WriteLine("The Service is running..");

System::String^ url = "http://localhost:2110/TestWebService.Host/SimpleService.svc";
EndpointAddress^ address = gcnew EndpointAddress(url);
ChannelFactory<ISimpleService^>^ channelFactory = gcnew ChannelFactory<ISimpleService^>(binding,address);
ISimpleService^ channel = channelFactory->CreateChannel();
channel->GetName("Rakshit"smilie;

//System::SimpleServiceClient^ obj= gcnew SimpleServiceClient();

((IChannel^)channel)->Close();
delete channelFactory;
servicehost->Close();
delete servicehost;
return 0;
}

An unhandled exception of type 'System.ArgumentException' occurred in System.ServiceModel.dll

Additional information: ServiceHost only supports class service types.

Thanks