我对WCF的基本配置有问题。我正在开发MobilePhone应用程序。首先,我创建了使用basicHttpBinding的测试桌面应用程序,一切都很好。接下来,我使用了相同的代码(唯一的区别是在ServerReference -在电话中,我使用了两个使用NetCFSvcUtil生成的服务器文件)。在电话应用程序中,我得到了端点,没有发现异常。下面我把我的配置。我将非常感谢您的帮助或建议。
致以问候。
电话方面的例外情况:
没有侦听http://localhost:4444/Service/PhoneService的端点可以接受消息。这通常是由不正确的地址或SOAP操作造成的。有关更多细节,请参见InnerException (如果存在)。
电话配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding" 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="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4444/Service/PhoneService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding"
contract="IPhoneService" name="BasicHttpBinding" />
</client>
</system.serviceModel>
**服务器配置的狂欢片段**
<service name="Server.PhoneService" behaviorConfiguration="Server.PhoneServiceBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="" contract="Server.IPhoneService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:4444/Service/PhoneService" />
</baseAddresses>
</host>
</service>
//______________________________//
<behavior name="Server.PhoneServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>*浏览器中的配置*
PhoneService服务
您已经创建了一个服务。
要测试此服务,您需要创建一个客户端并使用它调用该服务。您可以使用命令行中的svcutil.exe工具执行此操作,语法如下:
svcutil.exe http://localhost:4444/Service/PhoneService?wsdl
这将生成一个配置文件和一个包含客户端类的代码文件。将这两个文件添加到客户端应用程序中,并使用生成的客户端类调用服务。例如:
C#
class Test
{
static void Main()
{
PhoneServiceClient client = new PhoneServiceClient();
// Use the 'client' variable to call operations on the service.
// Always close the client.
client.Close();
}
}发布于 2011-03-21 22:29:58
这个问题是由不可用的互联网连接引起的。
https://stackoverflow.com/questions/5372249
复制相似问题