WCF客户端错误

时间:2015-11-24 12:51:33

标签: wpf wcf wcf-binding wcf-client wcf-hosting

我无法使用托管在Web IIS(IIS 8.0)上的WCF服务。我可以访问.svc页面并在我的WPF应用程序上添加对服务的引用,但是当我调用/调用某些wcf服务方法时,我得到了一个例外:

  

没有终点收听   可以接受该消息的mywebsite.com.br/blusync/BluService.svc。   这通常是由错误的地址或SOAP操作引起的。看到   InnerException(如果存在),以获取更多详细信息.System.Net.WebException:   远程服务器返回错误:(404)Not Found。\ r \ n at   System.Net.HttpWebRequest.GetResponse()\ r \ n at   System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannel Request.WaitForReply(时间跨度   超时)

由于地址正确,我认为错误是由某些安全/身份验证问题引起的。

以下是我如何使用该方法的示例:

MyServiceClient client = new ServiceClient();
client.Open();
client.GetDate();
client.Close();

这是我在客户端应用上的app.config:

    <?xml version="1.0" encoding="utf-8" ?><configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IBluService" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://www.mywebsite.com.br/blusync/BluService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBluService"
                contract="BluService.IBluService" name="BasicHttpBinding_IBluService" />
        </client>
    </system.serviceModel>
</configuration>

这是我在服务器端的web.config:

    ?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off"/>
    <!--<trust level="Full" /> -->
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>
    <client>
      <endpoint
        name="endpoint1"
        address="BluService"
        binding="basicHttpBinding"
        bindingConfiguration="basicHttpBinding_IBluService"
        behaviorConfiguration="IBluService_Behavior"
        contract="IBluService" >

        <metadata>
          <wsdlImporters>
            <extension
              type="Microsoft.ServiceModel.Samples.WsdlDocumentationImporter, WsdlDocumentation"/>
          </wsdlImporters>
        </metadata>

        <!--<identity>
          <userPrincipalName value="inbluser@inblu" />
        </identity>-->
      </endpoint>
    </client>

    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding_IBluService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
      <binding name="IstMembershipBinding">
       <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />     
       </security>
      </binding>
     </wsHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
          <behavior name=" IBluService_Behavior ">
              <clientVia />
          </behavior>
      </endpointBehaviors>    
      <serviceBehaviors>
        <behavior name="MetadataBehavior">
          <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="BluSync.BluService" behaviorConfiguration="MetadataBehavior">
        <endpoint address="" binding="basicHttpBinding" contract="BluSync.IBluService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://www.mywebsite.com.br/sync/BluService.svc" />
          </baseAddresses>
          <timeouts closeTimeout="00:01:10" openTimeout="00:09:00" />
        </host>
      </service>
    </services>
    <protocolMapping>
      <add scheme="https" binding="basicHttpsBinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
    <diagnostics>
        <messageLogging maxMessagesToLog="30000" 
                logEntireMessage="true" 
                logMessagesAtServiceLevel="true" 
                logMalformedMessages="true" 
                logMessagesAtTransportLevel="true">
        </messageLogging>
    </diagnostics>
  </system.serviceModel>
  <system.diagnostics>
    <sources>
        <source name="System.ServiceModel" 
                switchValue="Verbose, ActivityTracing" 
                propagateActivity="true" >
                <listeners>
                        <add name="xml" />
                </listeners>
        </source>
        <source name="System.ServiceModel.MessageLogging" 
                switchValue="Verbose">
                <listeners>
                        <add name="xml" />
                </listeners>
        </source>
    </sources>
    <sharedListeners>
            <add name="xml" 
                type="System.Diagnostics.XmlWriterTraceListener" 
                initializeData="e2eTraceTest.e2e" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
  <!--<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>-->
</configuration>

我的WCF托管在带有IIS 8.0的Web主机上,我将框架设置为4.0,并且我通过ftp发布项目。

我尝试了很多不同的绑定,但我是这项技术的新手..请帮助我们,我被困在这里!

0 个答案:

没有答案