我无法使用托管在 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 在 System.Net.HttpWebRequest.GetResponse()\r\n 在 System。 ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)
由于地址是正确的,我认为错误是由某些安全/身份验证问题引起的。
这是我如何使用该方法的示例:
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 发布项目。
我尝试了很多不同的绑定,但我是这项技术的新手。请帮帮我,我被困在这里了!