简体   繁体   中英

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. but when i try to post that on our production I am not able to consume the same service. Below is my 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.

I get below errormessage: There was no endpoint listening at http://url.com that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

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.

If you are able to access the service , check your client application web.config and find out the end point details for that service. If the endpoint url is mismatched you may get this error.

I fixed the error and below is the web config code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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