Select to view content in your preferred language

WebException Error

2631
1
Jump to solution
05-30-2012 01:16 PM
ScottDickison
Deactivated User
I am attempting to write a customized data upload task using FeatureLayerSyncAgent and the Synchronize() method for  Trimble Juno running Windows Mobile. When I attempt to execute the following code I get the WebException error. To see the error I've placed a breakpoint at the line "FLSA = null".


private void button1_Click(object sender, EventArgs e)
        {
            MobileServiceConnection MSC = new MobileServiceConnection();
            MSC.Url = @"http://servername/ArcGIS/rest/services/Mobile/KEPTS_Mobile/MobileServer";
            MapDocumentConnection MD = (MapDocumentConnection)MSC;
           
            MobileCache MC = new MobileCache(@"SD-MMC card\My Documents\ArcGIS Mobile\Kepts_Test\KEPTS_Mobile");
            MC.Open();
            List<string> FLList = new List<string>(new string[] { "Airspace" });
            foreach (string FLName in FLList)
            {
                FeatureLayer FL = MC.FeatureLayers[FLName];
                MessageBox.Show(MSC.GetFeatureCount(FL,null).ToString());
                FeatureLayerSyncAgent FLSA = new FeatureLayerSyncAgent(FL, MD);
                FeatureLayerSyncResults FLSR = (FeatureLayerSyncResults)FLSA.Synchronize();
                FLSA = null;
                FL = null;
            }
            MC.Close();  
            }

If anyone can point me in the right direction that would great!

Thanks,

Scott Dickison
Kentucky Transporation Cabinet.
0 Kudos
1 Solution

Accepted Solutions
ScottDickison
Deactivated User
Good morning,

I found a solution to this. I was using the incorrect URL for the service. I was attempting to use the REST address for the mobile service and not the SOAP address. The code I ended up using is as follows:

            MobileCache mobileCache1 = new MobileCache(@"SD-MMC card\My Documents\ArcGIS Mobile\MobileKEPTTest\KEPTS_Mobile"); //Get the Mobile Cache             MobileServiceConnection mobileServiceConnection1 = new MobileServiceConnection(); // Create connection back to SDE             mobileCache1.Close();              mobileServiceConnection1.Url = @"http://servername/ArcGIS/services/Mobile/KEPTS_MOBILE/MapServer/MobileServer"; //SOAP address of service (HAS TO BE IN THIS FORMAT)             mobileServiceConnection1.WebClientProtocolType = WebClientProtocolType.BinaryWebService;             MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1); MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();              mobileServiceConnection1.CreateCache(mobileCache1);             mobileCache1.Open();             try             {                 label1.Text = "Synchronizing with SDE...";                 mobileResults = (MobileCacheSyncResults)mobileSync.Synchronize();             }             catch (WebException ex)             {                 MessageBox.Show(ex.Message + " " + ex.StackTrace);             }             finally             {                 mobileCache1.Close();                 label1.Text = "Synchronize Complete...";                 button1.Enabled = false;             }

View solution in original post

0 Kudos
1 Reply
ScottDickison
Deactivated User
Good morning,

I found a solution to this. I was using the incorrect URL for the service. I was attempting to use the REST address for the mobile service and not the SOAP address. The code I ended up using is as follows:

            MobileCache mobileCache1 = new MobileCache(@"SD-MMC card\My Documents\ArcGIS Mobile\MobileKEPTTest\KEPTS_Mobile"); //Get the Mobile Cache             MobileServiceConnection mobileServiceConnection1 = new MobileServiceConnection(); // Create connection back to SDE             mobileCache1.Close();              mobileServiceConnection1.Url = @"http://servername/ArcGIS/services/Mobile/KEPTS_MOBILE/MapServer/MobileServer"; //SOAP address of service (HAS TO BE IN THIS FORMAT)             mobileServiceConnection1.WebClientProtocolType = WebClientProtocolType.BinaryWebService;             MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1); MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();              mobileServiceConnection1.CreateCache(mobileCache1);             mobileCache1.Open();             try             {                 label1.Text = "Synchronizing with SDE...";                 mobileResults = (MobileCacheSyncResults)mobileSync.Synchronize();             }             catch (WebException ex)             {                 MessageBox.Show(ex.Message + " " + ex.StackTrace);             }             finally             {                 mobileCache1.Close();                 label1.Text = "Synchronize Complete...";                 button1.Enabled = false;             }
0 Kudos