Wcf Windows Phone 8设备调试不工作
我正在尝试使一些应用程序连接到WCF服务。除了在实际设备上调试外,一切都很正常。它报告超时异常。我在使用emulator时没有问题,一切都正常 这是我的主页上的代码:Wcf Windows Phone 8设备调试不工作,wcf,windows-phone-7,windows-phone-8,windows-phone,Wcf,Windows Phone 7,Windows Phone 8,Windows Phone,我正在尝试使一些应用程序连接到WCF服务。除了在实际设备上调试外,一切都很正常。它报告超时异常。我在使用emulator时没有问题,一切都正常 这是我的主页上的代码: public partial class MainPage: PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); ServiceReference1.WCFClien
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();
}
[服务合同]
公共接口IExams
{
[经营合同]
列表加载检查();
}
从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();
}
}
公共类ExamService:IExams
{
公共ExamDataClasseSDataContext数据{get;set;}
公共ExamService()
{
数据=新的ExamDataClasseSDataContext();
}
公共列表加载考试(字符串un)
{
返回data.loadChecks(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>
从我的servicerences.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>
如果本地计算机上有WCF服务,则需要允许通过防火墙进行外部连接。此外,您需要将设备连接到PC的同一网络。即使如此,您也可以尝试使用PC IP而不是名称连接到服务(使用http://192.168.1.23/service
而非http://mypcname/service
)。你能发布你正在使用的代码吗?我已经编辑了这个问题。。我认为代码本身没有什么问题。。但我不确定。。我确实收缩了代码中的所有内容,以检查基本功能是否正常工作,但没有成功。您是否能够在浏览器中的真实设备上访问有关它的服务/元数据?我的意思是,该服务是否可以在设备上访问?@MayurTendulkar我真的不知道该怎么做,但当我尝试在emulator和设备IE中访问服务地址时,肯定会有不同。。我在emulator中获得了该服务的页面,但在手机中没有。我已经按照的说明进行了操作,并且我的计算机和手机位于同一个wifi网络上。在这种情况下,任何防火墙/防病毒程序都必须运行或阻止访问。还有一种情况是在其他端口上运行的服务。所以,正如Josue提到的,地址是。如果防火墙/防病毒,您还需要确保此端口处于打开状态。我没有安装任何防病毒软件,因为它阻止了对模拟器的访问,我调整了我正在使用的端口的防火墙入站规则。。大概是192.168.137.146:14584,我甚至试图完全关闭防火墙,但没有成功@MayurTendulkarI已经将listener添加到我的服务的web.config文件中,在Microsoft Trace service Viewer中,我得到了一些异常:Content-Type应用程序/soap+xml;charset=utf-8已发送到需要text/xml的服务;字符集=utf-8。客户端和服务绑定可能不匹配。