Joseph Schrag
2009-01-08 16:05:08 UTC
I have followed the tutorial at
http://liveside.net/developer/archive/2008/09/29/video-getting-started-with-the-virtual-earth-web-service.aspx
to set up a Virtual Earth Customer Service account and implemented the code
in my application to handle tokens (See my code below). However, after
several days, I am still not getting any data showing in the transaction
usage reports on the VE CSS website. Anyone have any ideas? Is there
something missing in my code?
ASPX page (condensed):
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="TransactionTest.aspx.cs"
Inherits="Mappeg_TransactionTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:ScriptManager ID='ScriptManager1' runat='server'>
<Scripts>
<asp:ScriptReference
Path='http://staging.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2' />
<asp:ScriptReference Path='TransactionTest.aspx.js' />
</Scripts>
</asp:ScriptManager>
<div id='myMap' style="position:relative; width:972px; height:591px; top:
0px; left: 0px;"></div>
C# Code behind (condensed):
using ...
using net.virtualearth.common.staging;
public partial class Mappeg_TransactionTest : System.Web.UI.Page
{
public string clientToken;
protected void Page_Load(object sender, EventArgs e)
{
clientToken = GetClientToken();
}
private string GetClientToken()
{
CommonService commonService = new CommonService();
commonService.Url =
"https://staging.common.virtualearth.net/find-30/common.asmx";
commonService.Credentials = new System.Net.NetworkCredential(<myIDhere>,
<myPasswordhere>);
// Create the TokenSpecification object to pass to GetClientToken.
TokenSpecification tokenSpec = new TokenSpecification();
// Use the Page object to retrieve the end-client’s IPAddress.
tokenSpec.ClientIPAddress = Page.Request.UserHostAddress;
// The maximum allowable token duration is 480 minutes (8 hours).
// The minimum allowable duration is 15 minutes.
tokenSpec.TokenValidityDurationMinutes = 480;
// Now get a token from the Virtual Earth Platform Token service.
return commonService.GetClientToken(tokenSpec);
}
}
Javascript file (Condensed):
function GetMap()
{
map = new VEMap('myMap');
map.SetClientToken("<%= clientToken %>");
map.LoadMap(new VELatLong(88.8888, -88.8888), 9, 'h', false,
VEMapMode.Mode3D, true);
map.AttachEvent('ontokenexpire', TokenExpirationHandler);
map.AttachEvent('ontokenerror', TokenErrorHandler);
}
function TokenExpirationHandler(e)
{
map.ShowMessage("Your Virtual Earth session has expired. Please refresh your
browser.");
}
function TokenErrorHandler(e)
{
alert("Token Error");
}
http://liveside.net/developer/archive/2008/09/29/video-getting-started-with-the-virtual-earth-web-service.aspx
to set up a Virtual Earth Customer Service account and implemented the code
in my application to handle tokens (See my code below). However, after
several days, I am still not getting any data showing in the transaction
usage reports on the VE CSS website. Anyone have any ideas? Is there
something missing in my code?
ASPX page (condensed):
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="TransactionTest.aspx.cs"
Inherits="Mappeg_TransactionTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:ScriptManager ID='ScriptManager1' runat='server'>
<Scripts>
<asp:ScriptReference
Path='http://staging.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2' />
<asp:ScriptReference Path='TransactionTest.aspx.js' />
</Scripts>
</asp:ScriptManager>
<div id='myMap' style="position:relative; width:972px; height:591px; top:
0px; left: 0px;"></div>
C# Code behind (condensed):
using ...
using net.virtualearth.common.staging;
public partial class Mappeg_TransactionTest : System.Web.UI.Page
{
public string clientToken;
protected void Page_Load(object sender, EventArgs e)
{
clientToken = GetClientToken();
}
private string GetClientToken()
{
CommonService commonService = new CommonService();
commonService.Url =
"https://staging.common.virtualearth.net/find-30/common.asmx";
commonService.Credentials = new System.Net.NetworkCredential(<myIDhere>,
<myPasswordhere>);
// Create the TokenSpecification object to pass to GetClientToken.
TokenSpecification tokenSpec = new TokenSpecification();
// Use the Page object to retrieve the end-client’s IPAddress.
tokenSpec.ClientIPAddress = Page.Request.UserHostAddress;
// The maximum allowable token duration is 480 minutes (8 hours).
// The minimum allowable duration is 15 minutes.
tokenSpec.TokenValidityDurationMinutes = 480;
// Now get a token from the Virtual Earth Platform Token service.
return commonService.GetClientToken(tokenSpec);
}
}
Javascript file (Condensed):
function GetMap()
{
map = new VEMap('myMap');
map.SetClientToken("<%= clientToken %>");
map.LoadMap(new VELatLong(88.8888, -88.8888), 9, 'h', false,
VEMapMode.Mode3D, true);
map.AttachEvent('ontokenexpire', TokenExpirationHandler);
map.AttachEvent('ontokenerror', TokenErrorHandler);
}
function TokenExpirationHandler(e)
{
map.ShowMessage("Your Virtual Earth session has expired. Please refresh your
browser.");
}
function TokenErrorHandler(e)
{
alert("Token Error");
}