2014-06-25 50 views
1

我有一個由我需要使用的客戶端提供的web服務。消費web服務時出錯

我使用WCFTestClient測試了webservice。 &我確認服務正在運行。

現在,我想消費使用C#代碼的web服務。我添加了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() 

我一直停留在這一點上,不知道錯誤意味着什麼,接下來我會做什麼。如果您有任何想法,請告訴我。

回答

0

我不得不從我的dll複製綁定標記的端點&並將它們複製到調用Web服務的其他UI程序的webconfig文件中。這解決了我的問題。