![](/img/trans.png)
[英]Cannot connect to webservice using the ip address but works with 127.0.0.1
[英]Webservice doesn't fire on host computer when using IP address
我不太清楚問題是什么,但是我將嘗試解釋當前的行為:
我有一個與CRM交互的Silverlight應用程序。 在按鈕上,單擊一些從CRM加載的數據。 此應用程序在我的IIS上本地發布。
從主機上:-我使用包含“ localhost”的URL訪問我的應用程序,該按鈕觸發了Web服務,並加載了數據。 -我使用了包含“ IP地址”的URL,但是該按鈕什么也不做,也沒有出現腳本錯誤。 (我的問題在這里)
從網絡上的另一台計算機上:-我使用了包含“ IP地址”的URL,它工作正常
有人可以指出為什么我不能在本地使用IP地址訪問我的應用程序嗎?
編輯:
單擊按鈕后面的代碼:
private void Contacts_Click(object sender, RoutedEventArgs e)
{
try
{
QueryExpression query = new QueryExpression();
query.EntityName = "contact";
query.ColumnSet = new ColumnSet() { AllColumns = true, Columns = new System.Collections.ObjectModel.ObservableCollection<string>(new String[]{ "" })};
query.PageInfo = new PagingInfo { Count = MaxRecordsToReturn, PageNumber = 1, PagingCookie = null };
OrderExpression oe = new OrderExpression();
oe.AttributeName = "fullname";
oe.OrderType = OrderType.Ascending;
query.Orders = new System.Collections.ObjectModel.ObservableCollection<OrderExpression>(new OrderExpression[] { oe }) ;
OrganizationRequest request = new OrganizationRequest() { RequestName = "RetrieveMultiple" };
request["Query"] = query;
IOrganizationService service = SilverlightUtility.GetSoapService();
service.BeginExecute(request, new AsyncCallback(Contact_ClickCallback), service);
}
catch (Exception ex)
{
//this.ReportError(ex);
}
}
private void Contact_ClickCallback(IAsyncResult result)
{
try
{
OrganizationResponse response = ((IOrganizationService)result.AsyncState).EndExecute(result);
EntityCollection results = (EntityCollection)response["EntityCollection"];
System.Collections.ObjectModel.ObservableCollection<StudentClass> resultsarray=getTwoDimensionalArray(results);
Dispatcher.BeginInvoke(delegate { EntityDataGrid.ItemsSource = resultsarray; });
}
catch (Exception ex)
{
//this.ReportError(ex);
}
}
函數:getTwoDimensionalArray,僅獲取返回的實體集合並創建類“ Contacts”的實例來保存返回的值。
聽起來像是回送檢查問題。 有關詳細信息,請參見此知識庫文章: http : //support.microsoft.com/kb/896861
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.