这是我第一次尝试使用WCF以及我的第一个Windows Mobile App。我一直在关注本教程:http://msdn.microsoft.com/en-us/library/cc488004(v=vs.90).aspx
我已经创建了一个WCF服务,弹出了WCF服务主机对话框,并说服务启动时没有错误。然而,当我尝试通过浏览器导航到它时它不起作用。我正在使用的所有内容都在运行Windows 7的本地计算机上。
我已禁用所有防火墙。
我在这里不知所措,它说它已经启动但我无法导航到它。我尝试时遇到了http 400错误。
元数据地址为http://myip:8731/ElectricReadingCacheSyncService
这是我的配置代码:
<system.serviceModel>
<services>
<service name="MiddleTierServiceLibrary.ElectricReadingCacheSyncService" behaviorConfiguration="MiddleTierServiceLibrary.ElectricReadingCacheSyncServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://MYIP:8731/ElectricReadingCacheSyncService/" />
</baseAddresses>
</host>
<endpoint
address=""
binding="basicHttpBinding"
contract="MiddleTierServiceLibrary.IElectricReadingCacheSyncContract">
<identity>
<dns value="MYIP"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MiddleTierServiceLibrary.ElectricReadingCacheSyncServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetai! lInFault s="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
非常感谢任何帮助!
编辑:这是客户端配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IElectricReadingCacheSyncContract"
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>
</bindings>
<client>
<endpoint address="http://MYIP:8731/ElectricReadingCacheSyncService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IElectricReadingCacheSyncContract"
contract="IElectricReadingCacheSyncContract" name="BasicHttpBinding_IElectricReadingCacheSyncContract" />
</client>
</system.serviceModel>
</configuration>
答案 0 :(得分:0)
您正在为配置添加基地址:
... add baseAddress =“http:// MYIP:8731 / ElectricReadingCacheSyncService /”/&gt;' ...
对于数据交换,您要添加“mex”:
mex会附加到您的基地址。在您的浏览器上,转到:
http://MYIP:8731/ElectricReadingCacheSyncService/的 MEX 强>
你应该看到结果。