没有端点侦听当我尝试构建项目时出现错误。在我的项目中,当客户端向服务发送电话号码时,服务器将返回用户拥有此电话号码的所有信息。Windows Phone - WCF-错误在
这是服务
namespace ICService
{
public class ProfileService : IProfileService
{
public lbl_Profile ViewProfile(int phonenumber)
{
Profileview profile = new Profileview();
return profile.ViewProfile(phonenumber);
}
}
public class Profileview
{
public lbl_Profile ViewProfile(int phonenumber)
{
try
{
ToPiDataContext db = new ToPiDataContext();
var query = (from m in db.lbl_Accounts
from n in db.lbl_Profiles
where m.AccountID == n.AccountID && m.Phonenumber == phonenumber
select new
{
n.AccountID
}).First();
var profile = (from m in db.lbl_Profiles
where m.AccountID == query.AccountID
select m).First();
return profile;
}
catch
{
return null;
}
}
}
}
在客户端
public partial class Profile : PhoneApplicationPage
{
public Profile()
{
InitializeComponent();
ProfileServiceClient profileClient = new ProfileServiceClient();
profileClient.ViewProfileCompleted += new EventHandler<ViewProfileCompletedEventArgs>(profileService_ViewProfileCompleted);
profileClient.ViewProfileAsync(phonenumber);
}
void profileService_ViewProfileCompleted(object sender, ViewProfileCompletedEventArgs e)
{
txbFirstName.Text = e.Result.FirstName;
txbLastName.Text = e.Result.LastName;
txbLocation.Text = e.Result.Location;
txbGenre.Text = e.Result.Genre;
}
}
在手机的配置在Web服务
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAccountService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_IProfileService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2183/AccountService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService"
contract="AccountService.IAccountService" name="BasicHttpBinding_IAccountService" />
<endpoint address="http://localhost:2183/ProfileService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProfileService"
contract="ProfileService.IProfileService" name="BasicHttpBinding_IProfileService" />
</client>
</system.serviceModel>
**向我们展示CONFIG!**大部分相关WCF的东西是在配置定义 - 什么里面的''部分 - 无论是在服务器还是客户端 - 没有它,我们不可能帮助 –
2012-03-30 05:26:26
谢谢,我在我的文章上编辑过。你能帮我解决这个问题吗? – 2012-03-30 09:38:11