“没有端点监听” - 配置不匹配也许?

时间:2015-09-16 05:43:57

标签: c# wcf iis

我得到了

  

“没有端点在https://localhost/BassCoastServices/GeneralUtilityService.svc监听   可以接受这个消息。这通常是由错误的地址引起的   或SOAP动作。有关详细信息,请参阅InnerException(如果存在)。“

当我从客户端调用GeneralUtilityService时

  

“没有频道主动收听”https://laura-laptop/BassCoastServices/GeneralUtilityService.svc“。   这通常是由错误的地址URI引起的。确保   发送消息的地址与a上的地址匹配   服务正在倾听。“

当我调试w3wp时出现

我可以使用某种工具来确保客户端和服务器配置文件排队吗? 如果这是一个简单的修复,请参阅下面的应用程序和Web配置文件。

的App.config

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="Username" value="sampleuser"/>
    <add key="Password" value="samplepassword"/>
    <add key="basePath" value="C:\Temp"/>
  </appSettings>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <bindings>
      <wsHttpBinding>
        <binding name="standardBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" allowCookies="true">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="163840" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="01:00:00" enabled="false"/>
          <security mode="TransportWithMessageCredential" >
            <transport clientCredentialType="Certificate" proxyCredentialType="None"  />
            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientCertificateBehavior">
          <callbackDebug includeExceptionDetailInFaults="true"/>
          <clientCredentials>
            <clientCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
            </clientCertificate>
          </clientCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <client>

      <endpoint address="https://localhost/BassCoastServices/GeneralUtilityService.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="standardBinding" contract="Adapt.WCF.IGeneralUtilityService" name="IGeneralUtilityServiceEndPoint">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>

    </client>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>
</configuration>

的Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <appSettings>

    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
    <add key="DatabaseConnectionString" value="Data Source=(local)\SQL2014;Initial Catalog=XIVICProduction;User ID=sa;Password=sameplepassword;MultipleActiveResultSets=True"/>
    <add key="LogFilePath" value="C:\inetpub\wwwroot\Xivic\BassCoastServices\Log\Log.txt"/>
    <add key="AllowMissingExternalIDs" value="true"/>

    <!--No need to change-->
    <add key="LogFileTypeLevel" value="Error"/>
    <add key="SqlServerDateTimeStyle" value="103"/>
    <add key="DatabaseType" value="Sql"/>
    <add key="EnforceSecurityAtBusinessRulesLayer" value="false"/>
    <add key="DateComparisonInaccuracy" value="35000"/>
    <add key="CacheAccessItemsAtBusinessLayer" value="true"/>
    <add key="CacheRecordsAtDataLayer" value="true"/>
    <add key="SesionTimeout" value="1440"/>
  </appSettings>

  <system.serviceModel>

    <services>
      <!-- ENDPOINTS -->
      <service name="IGeneralUtilityServiceEndPoint" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="wsHttpBinding" contract="Adapt.WCF.IGeneralUtilityService" bindingConfiguration="wsHttpEndpointBinding"/>
      </service>

    </services>

    <!-- BEHAVIOURS -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="UserNameBehaviour">
          <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Adapt.WCF.Security.CustomUserNameValidator, Adapt.WCF" />
            <serviceCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
            </serviceCertificate>
          </serviceCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!-- BINDINGS -->
    <bindings>

      <wsHttpBinding>
        <binding name="wsHttpEndpointBinding">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>

    </bindings>

  </system.serviceModel>

  <system.diagnostics>
        <sources>
            <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
                <listeners>
                    <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "C:\inetpub\wwwroot\Xivic\BassCoastServices\Log\Traces.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>

  <!--startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
  </startup-->

</configuration>

致电WCF

_Channel = GetProxy<IGeneralUtilityService>();
_Channel.BeginTransaction(transactionId);
_Channel.CommitTransaction(transactionId);

public static T GetProxy<T>()
{
    var channelFactory = new ChannelFactory<T>(string.Format("{0}EndPoint", typeof(T).Name));
    channelFactory.Credentials.UserName.UserName = ConfigurationSettings.AppSettings["Username"];
    channelFactory.Credentials.UserName.Password = ConfigurationSettings.AppSettings["Password"];
    var workflowProxy = channelFactory.CreateChannel();
    return workflowProxy;
}

提前致谢!

更新:我不知道我做了什么,但现在我正在

  

“服务http://localhost/BassCoastServices/GeneralUtilityService.svc不支持内容类型application / soap + xml; charset = utf-8。客户端和服务绑定可能不匹配。”

2 个答案:

答案 0 :(得分:0)

您的问题是您创建渠道工厂的方式。一些如何无法获得正确的EndpointConfigurationName。

我不太熟悉如何在Channel Factory中仅使用EndpointConfigurationName作为参数,但您可以这样尝试:

var channelFactory = new ChannelFactory<T>("*", new EndpointAddress("https://localhost/BassCoastServices/GeneralUtilityService.svc"));

答案 1 :(得分:0)

嗯,我不知道问题是什么,但对于任何寻找这个问题的解决方案的人来说,这是我的网络和应用程序配置文件:

<强>的Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>

    <!--Please configure-->
    <!--Laura Local-->
    <add key="DatabaseConnectionString" value="Data Source=(local)\SQL2014;Initial Catalog=XIVICProduction;User ID=sa;Password=samplepassword;MultipleActiveResultSets=True"/>

    <!--No need to change-->
    <add key="LogFilePath" value="C:\Temp\Log\log.txt" />
    <add key="LogFileTypeLevel" value="Information" />
    <add key="SqlServerDateTimeStyle" value="103" />
    <add key="DatabaseType" value="Sql" />
    <add key="EnforceSecurityAtBusinessRulesLayer" value="false" />
    <add key="DateComparisonInaccuracy" value="35000" />
    <add key="CacheAccessItemsAtBusinessLayer" value="true" />
    <add key="CacheRecordsAtDataLayer" value="true" />

    <!--Email Configuration-->
    <!--add key="EmailAlertHost" value=""[INSERT="" HOST="" ADDRESS=""]/>
    <add key="EmailAlertUsername" value=""[INSERT="" USERNAME=""]/>
    <add key="EmailAlertPassword" value=""[INSERT="" PASSWORD=""] />
    <add key="EmailAlertReplyToAddress" value=[INSERT REPLY TO ADDRESS] />
    <add key="EmailAlertToAddress" value=""/>
    <add key="EmailAlertCCAddress" value=""/>
    <add key="EmailAlertSubject" value="*WARNING* - A Fatal Error Occurred  @ {0} - *WARNING*"/>
    <add key="EmailAlertPriority" value="High"/-->

  </appSettings>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>

  <system.web>
    <compilation debug="true"/>
  </system.web>

  <system.serviceModel>

    <services>
      <!--AssetInventoryService-->
      <service name="Adapt.WCF.AssetInventory.AssetInventoryService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.AssetInventory.AssetInventoryService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--AssetValuationUtilityService-->
      <service name="Adapt.WCF.AssetValuation.AssetValuationUtilityService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.IAssetValuationUtilityService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--CodeGenerationService-->
      <service name="Adapt.WCF.CodeGeneration.CodeGenerationService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.CodeGeneration.CodeGenerationService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--CodeUtilityService-->
      <service name="Adapt.WCF.CodeGeneration.CodeUtilityService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.CodeGeneration.ICodeUtilityService" bindingConfiguration="UserNameBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/CodeUtilityService.svc" />
          </baseAddresses>
        </host>
      </service>
      <!--DataSchemaService-->
      <service name="Adapt.WCF.DataSchema.DataSchemaService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.DataSchema.DataSchemaService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--DataTransactionService-->
      <service name="Adapt.WCF.DataTransaction.DataTransactionService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.DataTransaction.DataTransactionService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--GeneralUtilityService-->
      <service name="Adapt.WCF.GeneralUtilityService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.IGeneralUtilityService" bindingConfiguration="UserNameBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/GeneralUtilityService.svc" />
          </baseAddresses>
        </host>
      </service>
      <!--SecurityService-->
      <service name="Adapt.WCF.Security.SecurityService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.Security.SecurityService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--SyncService-->
      <service name="Adapt.WCF.SyncService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.ISyncService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--SystemSetupService-->
      <service name="Adapt.WCF.SystemSetup.SystemSetupService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.SystemSetup.SystemSetupService" bindingConfiguration="UserNameBinding" />
      </service>
      <!--TaskManagementService-->
      <service name="Adapt.WCF.TaskManagement.TaskManagementService" behaviorConfiguration="UserNameBehaviour">
        <endpoint binding="customBinding" contract="Adapt.WCF.TaskManagement.TaskManagementService" bindingConfiguration="UserNameBinding" />
      </service>
    </services>

    <!-- BEHAVIOURS -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="UserNameBehaviour">
          <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Adapt.WCF.Security.CustomUserNameValidator, Adapt.WCF" />
            <serviceCertificate findValue="localhost" x509FindType="FindByIssuerName" storeLocation="LocalMachine" storeName="My">
            </serviceCertificate>
          </serviceCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!-- BINDINGS -->
    <bindings>
      <customBinding>
        <binding name="UserNameBinding" closeTimeout="23:00:00" openTimeout="23:00:00" receiveTimeout="23:00:00" sendTimeout="23:00:00">
          <security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
            <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated">
            </secureConversationBootstrap>
          </security>
          <textMessageEncoding>
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </textMessageEncoding>
          <httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>
  <!--<system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "c:\temp\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>-->
</configuration>

<强>的App.config

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="Username" value="dspec"/>
    <add key="Password" value="samplepassword"/>
    <add key="BasePath" value="c:\FileDrop"/>
  </appSettings>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <bindings>
      <wsHttpBinding>
        <binding name="standardBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" allowCookies="true">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="163840" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="01:00:00" enabled="false"/>
          <security mode="Message">
            <transport clientCredentialType="Certificate" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
          </security>
        </binding>
      </wsHttpBinding>



    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientCertificateBehavior">
          <callbackDebug includeExceptionDetailInFaults="true"/>
          <clientCredentials>
            <serviceCertificate>
              <authentication certificateValidationMode="None"/>
            </serviceCertificate>
          </clientCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <client>

      <endpoint address="http://localhost/BassCoastServices/GeneralUtilityService.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="standardBinding" contract="Adapt.WCF.IGeneralUtilityService" name="IGeneralUtilityServiceEndPoint">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>

    </client>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>
</configuration>