简体   繁体   中英

WCF Service for Windows Mobile App running but I cannot connect

This is my first attempt at using WCF as well as my first Windows Mobile App. I have been following this tutorial: http://msdn.microsoft.com/en-us/library/cc488004(v=vs.90).aspx

I have created a WCF service, the WCF Service host dialog box pops up and says the service is started with no errors. Yet when I try to navigate to it through my browser it does not work. Everything I am using is on my local machine which is running Windows 7.

I have disabled all firewalls.

I am at a loss here, it says it is started yet I cannot navigate to it. I get an http 400 error when I try.

The metadata address is http://myip:8731/ElectricReadingCacheSyncService

Here is my config code:

<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>

Any help is greatly appreciated!

EDIT: Here is the client config

<?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> 

You're adding a base address to the configuration:

... add baseAddress="http://MYIP:8731/ElectricReadingCacheSyncService/"/>' ...

For the data exchange, you're adding "mex":

The mex gets appended to your base address. On your browser, go to:

http://MYIP:8731/ElectricReadingCacheSyncService/ mex

and you should see the results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM