沒有端點偵聽當我嘗試構建項目時出現錯誤。在我的項目中,當客戶端向服務發送電話號碼時,服務器將返回用戶擁有此電話號碼的所有信息。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