我已经创建了一个使用ASP.NET 4的WCF服务,并试图在我自己的Web应用程序项目中连接到它,它给了我“不能找到默认的端点元素“错误。在Web应用程序引用自己的服务中找不到默认的端点元素错误
这个类似的问题的答案似乎没有帮助我,因为他们似乎都处理引用服务和缺少配置文件的外部项目。
该服务在其方法直接使用时起作用(例如:JS调用)。
任何想法?请查看下面我serviceModel部分:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled = "true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<services>
<service name="MapiWebService.CrmService" behaviorConfiguration="metadataBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:64049/Service/CrmService.svc"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="MapiWebService.CrmService" behaviorConfiguration="webHttpBehavior" />
<endpoint address="http://localhost:64049/Service/CrmService.svc/mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
我这里还有我的服务类的开头几行:
namespace MapiWebService
{
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CrmService : PortalService
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string Authenticate(string username, string password)
谢谢你的回答。但是,它并没有解决这个问题。我收到了同样的错误。 – denious 2013-03-01 21:45:37
另外,请记住,通常我甚至不需要指定服务的地址来引用它,因为我在同一个项目中。我只需在VS中打开添加服务参考对话框,然后单击发现>选择我的服务,然后就可以使用了。 – denious 2013-03-01 21:52:38
之前未能注意到它,但'MapiWebService.CrmService'是你的'ServiceContract'? – Flowerking 2013-03-01 23:05:00