2013-08-16 47 views
0

我试图让一些应用程序连接到WCF服务。除了在实际设备上进行调试以外,一切工作都很好。它报告TimeOut异常。我没有使用模拟器的问题,在那里一切都很好。Windows Phone 8设备调试不起作用

这是从我的炫魅代码:

public partial class MainPage: PhoneApplicationPage 
{ 
    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 
     ServiceReference1.WCFClient serviceClient = new ServiceReference1.WCFClient(); 

     serviceClient.LoadExamsAsync("Marco"); 
     serviceClient.LoadExamsCompleted += serviceClient_LoadExamsCompleted; 


    } 

    void serviceClient_LoadExamsCompleted(object sender, ServiceReference1.LoadExamsCompletedEventArgs e) 
    { 
     lls2.ItemsSource = e.Result; // longlistselector 
    } 
} 

从IExams.cs:

[ServiceContract] 
public interface IExams 
{ 

    [OperationContract] 
    List<LoadExamsResult> LoadExams(); 

} 

和Exams.svc.cs:创建

public class ExamsService : IExams 
{ 
    public ExamsDataClassesDataContext data { get; set; } 
    public ExamsService() 
    { 
     data = new ExamsDataClassesDataContext(); 
    } 

    public List<LoadExamsResult> LoadExams(string un) 
    { 
     return data.LoadExams(un).ToList(); 
    } 
} 

LinqToSql类自动,我从Sql Server中的数据库中调用存储过程..

这是我的web.config文件:

<?xml version="1.0"?> 
<configuration> 
    <connectionStrings> 
    <add name="ConnectionString" connectionString="Data Source=Alex;Initial  Catalog=Ispiti;Integrated Security=True" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" executionTimeout="1200"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</configuration> 

,并从我的ServiceReferences.ClientConfig

<configuration> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="basicHttpBinding_IExams" maxBufferSize="2147483647" 
        maxReceivedMessageSize="2147483647"> 
        <security mode="None" /> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://192.168.137.146:14584/Exams.svc" binding="basicHttpBinding" 
       bindingConfiguration="basicHttpBinding_IExams" contract="ServiceReference1.IExams" 
       name="basicHttpBinding_IExams" /> 
     </client> 
    </system.serviceModel> 
</configuration> 
+0

你可以发布你使用的代码吗? – Meryovi

+0

我编辑了这个问题..我不认为有代码本身的问题..但我不知道..我没有收缩代码中的所有东西来检查基本的东西是否会工作,但没有成功。 – alexv

+0

您是否能够在浏览器内的真实设备上访问关于它的服务/元数据?我的意思是说,服务是否可以在设备上访问? –

回答

0

如果你有你的本地计算机上的WCF服务,你需要允许外部连接throught防火墙。另外,您需要将您的设备连接到PC的同一网络。即使这样,您也可以尝试使用PC IP连接到服务,而不是名称(使用http://192.168.1.23/service而不是http://mypcname/service)。

+0

我已经遵循http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx的说明,而我的电脑和我的电话在同一个wifi上网络。 – alexv

+0

在这种情况下,任何防火墙/防病毒程序都必须运行或阻止访问。还有一种情况是服务在其他端口上运行。所以,正如Josue所说,地址将是http://192.168.1.23:XXXX。如果是防火墙/防病毒,您还需要确保该端口是开放的。 –

+0

我没有安装任何防病毒软件,因为它阻止了对模拟器的访问,我调整了我使用的端口的防火墙入站规则..这就像192.168.137.146:14584,我甚至试图完全关闭防火墙,但没有成功。 @MayurTendulkar – alexv

相关问题