繁体   English   中英

在Azure托管WCF中找不到端点

[英]Cannot find Endpoint in Azure Hosted WCF

我在高空搜寻了我在Azure中托管WCF时已经放弃的问题的答案。 现在正在问这个问题,希望有人可以回答。

我的IIS7中的WCF正常运行,并且我的客户端应用程序已顺利连接到它。 所有这些都在本地工作。 我的WCF配置文件中有此绑定配置:

<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>

如您所见,我有2个端点,一个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>'

这很奇怪,因为这意味着我的应用程序未连接到.cloudapp.net。 因此,我尝试使用浏览器调用某些服务方法。 Fiddler告诉我响应是“ HTTP 400”。 在引用端点地址的URL之后,我还仔细检查了生成的client-config文件,该地址是正确的。

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>

Azure WSDL

<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。 查找client / endpoint元素,如下所示:

  <?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(Google的DNS服务器),并且在大多数情况下可以正常工作(几分钟后您可以将其更改为自动)。

离开这个对于那些谁在同样的问题绊倒:

我检查,我提供我的服务配置文件的命名空间 ,我对命名空间录入错误愚蠢的我:)

暂无
暂无

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

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