简体   繁体   English

WCF服务正在开发服务器上运行,但在生产环境中无法正常运行

[英]WCF service is working on dev server but on production it is not woking

I have a .net client and I am consuming the WCF service and able to do that sucessfully. 我有一个.net客户端,正在使用WCF服务,并且能够成功完成该操作。 but when i try to post that on our production I am not able to consume the same service. 但是,当我尝试将其发布到我们的产品中时,就无法使用相同的服务。 Below is my web.config : 以下是我的web.config:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyBehavior">
      <useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TestProject.Implementations.AuthenticateUser,TestProject"/>
        <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="TestProject.Implementations.ServiceCustom" behaviorConfiguration="MyBehavior">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SampleServiceBinding" contract="TestProject.Interfaces.IServiceCustom"></endpoint>
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"></endpoint>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="SampleServiceBinding">
      <security mode ="Message">
        <message clientCredentialType="UserName"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

and also I want to make my service HTTPS enabled. 我也想启用我的服务HTTPS。

I get below errormessage: There was no endpoint listening at http://url.com that could accept the message. 我收到以下错误消息:在http://url.com上没有端点可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

This error clearly suggest that the WCF service you are trying to access is not clearly hosted, or the address you are using to connect to is not pointing to the service, make sure by using the address in a browser you are able to access that service. 该错误明确表明您尝试访问的WCF服务未明确托管,或者您用于连接的地址未指向该服务,请确保通过使用浏览器中的地址可以访问该服务。

If you are able to access the service , check your client application web.config and find out the end point details for that service. 如果您能够访问该服务,请检查您的客户端应用程序web.config并找出该服务的端点详细信息。 If the endpoint url is mismatched you may get this error. 如果端点网址不匹配,则可能会出现此错误。

I fixed the error and below is the web config code: 我已修复错误,以下是Web配置代码:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyBehavior">
<useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"  />
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TestProject.Implementations.AuthenticateUser,TestProject"/>
        <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="TestProject.Implementations.Test" behaviorConfiguration="MyBehavior">
    <endpoint address="http://rul" binding="wsHttpBinding" bindingConfiguration="SampleServiceBinding" contract="TestProject.Interfaces.Test"></endpoint>
<endpoint address="https:url" binding="wsHttpBinding" bindingConfiguration="SampleServiceBindingHttps" contract="TestProject.Interfaces.ITest"></endpoint>
    <endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex"></endpoint>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="SampleServiceBinding">
      <security mode="Message">
        <message clientCredentialType="UserName"/>
      </security>
    </binding>
<binding name="SampleServiceBindingHttps">
  <security mode="TransportWithMessageCredential">
    <message clientCredentialType="UserName"/>
  </security>
    </binding>
  </wsHttpBinding>
</bindings>

I changed the security mode to TransportWithMessageCredential mode and change few config like binding = "mexHttpsBinding" 我将安全模式更改为TransportWithMessageCredential模式,并更改了一些配置,例如binding =“ mexHttpsBinding”

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

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