C# 在Azure托管的WCF中找不到终结点
我在Azure中托管WCF时遇到了一个问题,为此我到处寻找答案,但我已经放弃了。我现在问这个问题,希望有人能回答 我的WCF在IIS7中工作得很好,我的客户端应用程序已经顺利连接到它。这一切都在当地起作用。我的WCF配置文件中有此绑定配置:C# 在Azure托管的WCF中找不到终结点,c#,wcf,azure,C#,Wcf,Azure,我在Azure中托管WCF时遇到了一个问题,为此我到处寻找答案,但我已经放弃了。我现在问这个问题,希望有人能回答 我的WCF在IIS7中工作得很好,我的客户端应用程序已经顺利连接到它。这一切都在当地起作用。我的WCF配置文件中有此绑定配置: <system.serviceModel> <standardEndpoints /> <bindings> <basicHttpBinding> <binding name="basicHt
<system.serviceModel>
<standardEndpoints />
<bindings>
<basicHttpBinding>
<binding name="basicHttp" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" allowCookies="true" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttp" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="SurveyWCFService.SurveyService">
<clear />
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="basicHttp"
bindingName="basicHttp" contract="SurveyWCFService.SurveyService" />
<endpoint address="json" behaviorConfiguration="jsonBehavior"
binding="webHttpBinding" bindingConfiguration="webHttp" contract="SurveyWCFService.SurveyService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
如您所见,我有两个端点,一个用于连接到我的服务的C#应用程序的SOAP端点,一个用于使用REST访问它的客户端的JSON命名端点。我使用“Azure Web角色”模板中的默认配置将其部署到Azure,我的客户端已经可以访问Azure生成的给定URL。但奇怪的是:
1) 每当我的客户机使用任何给定的服务方法时,它都会返回此异常:
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at
http://<hostedservicename>/SurveyService.svc that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. --->
System.Net.WebException: The remote name could not be resolved: '<hostedservicename>'
System.ServiceModel.EndpointNotFoundException:在上没有端点侦听
http:///SurveyService.svc 这可以接受这个信息。
这通常是由不正确的地址或SOAP操作引起的。
有关更多详细信息,请参阅InnerException(如果存在)。->
System.Net.WebException:无法解析远程名称:“”
这很奇怪,因为这意味着我的应用程序没有连接到.cloudapp.net。所以我试着用我的浏览器调用一些服务方法。Fiddler告诉我响应是“HTTP 400”。在引用端点地址的URL后,我还仔细检查了生成的客户端配置文件,并且地址是正确的
2) Azure已决定用自己的端点和绑定替换我的端点和绑定。当我使用Fiddler检查并检查wsdl文件时,我得出了这个结论,下面是wsdl文件的底部部分:
本地WSDL
<wsdl:service name="SurveyService"><wsdl:port name="basicHttp_SurveyService"
binding="tns:basicHttp_SurveyService"><soap:address location="http://localhost
/SurveyServiceLibrary/SurveyService.svc/soap"/></wsdl:port></wsdl:service>
<wsdl:service name="SurveyService"><wsdl:port name="BasicHttpBinding_SurveyService"
binding="tns:BasicHttpBinding_SurveyService"><soap:address location=
"http://<hostedservicename>.cloudapp.net/SurveyService.svc"/></wsdl:port>
</wsdl:service>
Azure WSDL
<wsdl:service name="SurveyService"><wsdl:port name="basicHttp_SurveyService"
binding="tns:basicHttp_SurveyService"><soap:address location="http://localhost
/SurveyServiceLibrary/SurveyService.svc/soap"/></wsdl:port></wsdl:service>
<wsdl:service name="SurveyService"><wsdl:port name="BasicHttpBinding_SurveyService"
binding="tns:BasicHttpBinding_SurveyService"><soap:address location=
"http://<hostedservicename>.cloudapp.net/SurveyService.svc"/></wsdl:port>
</wsdl:service>
如何使我的WCF像在本地环境中一样工作?我需要在WCF上进行一些配置吗?在Azure上?我建议您看看调用您的WCF服务的应用程序。我的印象是它没有使用完整的URL。查找客户机/端点元素,如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
...
<client>
<endpoint address="http://<hostedservicename>.cloudapp.net/SurveyService.svc" ... />
</client>
</system.serviceModel>
</configuration>
...
哦,远程名称无法解析错误也可能意味着您尚未获得DNS复制。在这种情况下,我倾向于手动将DNS服务器更改为8.8.8.8(谷歌的DNS服务器),大多数情况下都可以正常工作(几分钟后您可以将其更改为自动)。将此留给那些遇到相同问题的人:
我检查了我在服务配置文件中提供的名称空间,名称空间上有一个错误键入,愚蠢的我:)谢谢你的提示,已经检查过了,客户端调用了正确的端点地址,但奇怪的是,当我使用本地WCF时,它会在客户端配置上生成正确的端点和行为配置(它会生成SOAP配置)。使用Azure托管的WCF,它会生成某种默认绑定配置。