简体   繁体   English

如何通过WEB应用程序->类库-> WCF服务调用WCF服务?

[英]How to call WCF service by WEB App -> Class Library -> WCF Service?

I have a WCF Service Project. 我有一个WCF服务项目。 I have another Class library project where I am calling the WCF service. 我有另一个类库项目,在这里我要调用WCF服务。 And from a Web Application i am callign the class librabry. 从Web应用程序中,我将类称为librabry。

In the Class library I am writing 在类库中,我正在写

new ChannelFactory<CompanyServiceContract>("CompanyServiceEndPoint")

But an exception is coming which says unable to find the End point "CompanyServiceEndPoint". 但是即将出现一个异常,该异常无法找到端点“ CompanyServiceEndPoint”。

I have seen this question Could not find default endpoint element but I don't know about WS configuration settings into the main projects app.config 我已经看到了这个问题, 找不到默认的终结点元素,但是我不知道将WS配置设置添加到主项目app.config中

Can someone please help? 有人可以帮忙吗?

Shouldn't "CompanyServiceEndPoint" actually be an endpoint? “ CompanyServiceEndPoint”实际上不应该是端点吗? (a string url to the service method, eg: "http://me.me.com/myService" or an EndpointAddress). (服务方法的字符串url,例如:“ http://me.me.com/myService”或EndpointAddress)。

Can you access your wcf endpoint by other means? 您可以通过其他方式访问wcf端点吗? a browser? 浏览器? Fiddler ? 小提琴手? WcfTestClient? WcfTestClient?

Did you define an endpoint for the scv in code? 您是否在代码中为scv定义了端点? eg: http://msdn.microsoft.com/en-us/library/ms734681.aspx 例如: http : //msdn.microsoft.com/en-us/library/ms734681.aspx

I think in the first instance you need to find out if the fault is with the service or the client that calls the service. 我认为,首先,您需要确定故障是否出在服务或调用服务的客户端上。 If you can hit the service with any of the clients above - then look to the client. 如果您可以通过以上任何一个客户端使用该服务,请寻找该客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM