2011-03-20 96 views
1

我有WCF的基本配置問題。我正在開發MobilePhone應用程序。首先,我創建了使用basicHttpBinding的測試桌面應用程序,並且一切都很好。 接下來我使用了相同的代碼(唯一區別在於ServerReference - 在手機中,我使用了使用NetCFSvcUtil生成的兩個服務器文件)。在電話應用程序中,我得到的端點沒有發現異常。 下面我將我的配置。我會很感激的幫助或建議。WCF配置 - basicHttpbinding

問候。

異常在電話那邊:

有沒有終點在 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> 

**服務器配置的revelant片段**

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

* 配置*

電話服務服務

您已創建服務。

要測試此服務,您需要 創建一個客戶端並使用它來調用 服務。

svcutil.exe的 http://localhost:4444/Service/PhoneService?wsdl

這將生成一個配置文件 和包含 客戶端代碼文件:您可以使用命令行 以下語法的 svcutil.exe的工具做到這一點類。將這兩個文件添加到您的客戶端應用程序的 ,並使用生成的客戶端類別 調用 服務。例如:

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(); 
    } 
} 
+0

您是否從另一臺設備(例如另一臺開發計算機)測試了客戶端配置? – 2011-03-20 23:40:43

+0

嗨,我已經測試了我的筆記本電腦上的所有東西 - 沒有防火牆。 – user648518 2011-03-21 02:13:24

回答

2

問題是由不可用互聯網連接造成的。