Ошибка при использовании веб-службы

1

У меня есть веб-сервис, предоставляемый клиентом, который мне нужно потреблять.

Я протестировал веб-сервис с помощью WCFTestClient. & Я подтвердил, что служба работает.

Теперь я хочу использовать webservice с помощью кода С#. Я добавил URL-адрес веб-службы в качестве ссылки на службу.

Я назвал свою служебную ссылку как PG_WS. Я закончил часть своего кода.

Когда я пытаюсь отладить код, как только я дойду до строки:

 PG_WS.ServiceSoapClient ws = new PG_WS.ServiceSoapClient();

Я получаю сообщение об ошибке:

    Message: System.InvalidOperationException: Could not find default endpoint 
element that references contract 'PG_WS.ServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
       at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
       at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
       at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
       at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
       at System.ServiceModel.ChannelFactory'1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
       at System.ServiceModel.ConfigurationEndpointTrait'1.CreateSimplexFactory()
       at System.ServiceModel.ConfigurationEndpointTrait'1.CreateChannelFactory()
       at System.ServiceModel.ClientBase'1.CreateChannelFactoryRef(EndpointTrait'1 endpointTrait)
       at System.ServiceModel.ClientBase'1.InitializeChannelFactoryRef()
       at System.ServiceModel.ClientBase'1..ctor()

Я застрял в этой точке, не зная, что означает ошибка, и что я могу сделать дальше. Пожалуйста, дайте мне знать, если у вас есть идеи.

Теги:
soap
web-services
visual-studio-2012

1 ответ

0
Лучший ответ

Мне пришлось скопировать конечные точки и теги привязки из моей dll и скопировать их в файл webconfig моей другой программы пользовательского интерфейса, которая вызывает веб-службу. Это решило мою проблему.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню