001487: Failed to update the published service with the server-side data location. Please see the server’s log for more details


Ho ho ho…getting this error when trying to publish a map? After upgrade? I got this error after upgrade from 10.3.1 and 10.4.1. I made several calls to Esri support, no help at all, they were thinking about file permission. I said what? How come file permission got change after upgrade? It doesn’t make sense and I said the account for ArcGIS server service is member of Administrator group and should have full permission to any files/folders.

Anyway…let me give you some background. After upgrade, I tried to publish a simple map that using Oracle database, so it means I used registered database from data store, it kept fail and threw the error. I checked the server log and I found this:

Failed swizzling the service.

Then

Failed to rename cache folder.

Then

Failed to create the service.: Updating the server connection string for layer Entries failed. Attempted connection string was ENCRYPTED_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;SERVER=sde;INSTANCE=”DSID=ffffffffffffffffffffffff”;DBCLIENT=oracle;DB_CONNECTION_PROPERTIES=TEST;PROJECT_INSTANCE=sde;USER=ARCSDE;VERSION=SDE.DEFAULT;AUTHENTICATION_MODE=DBMS. Table name is ARCSDE.COUNTIES. Please verify the data exists on the server.

Wow..first..what is swizzling? like mixing drink? And the last error message that made me puzzling, what? Verify the data exists on the server?

I did run Validate All on Server Manager, all showed green checked and did the same from ArcCatalog, all showed green as well. So it meant both from server and from local, it could connect and verify the database connection. So what is wrong then?

As I mentioned in the beginning, I called Esri support and I did my own search on Google. I found some interesting info.

  1. Bug – what? bug? Really?, here is the link, http://support.esri.com/download/7397 . Then it would be easy for me, just apply the patch and will work. Apparently no…the patch didn’t fix the issue.
  2. Found something in ArcGIS Pro reference, http://pro.arcgis.com/en/pro-app/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-01476-01500-001487.htm . Well…it didn’t make sense for my case.
  3. Found this thread, https://geonet.esri.com/thread/173653 … Well…very promising…until someone named, “Buddhatown”, gave a link
  4. Here is the link, https://geonet.esri.com/thread/177553#comment-614422 . Some gave steps on how to publish a service “manually” which is create MSD file and then publish from Admin site.
  5. Finally, inside that thread, someone named “twheagle-co-nz-esridist” gave this tip..THIS IS REAL HELP. Exactly the same as my case.

 

Let me give you my tips on how to fix:

  1. Check if your …\config-store\data has dsconnections.lst file or not, if not, continue below otherwise, please stop, it doesn’t apply to your caseJ.
  2. Find other site that working fine, has the same connection/registered database, copy the whole \data folder to the broken site AND copy dsconnections.lst file to all servers that member of the site in this location …\ArcGIS\Server\DatabaseSupport. REMEMBER: when you do that, you must stop ArcGIS server service on both source and target.
  3. If you can’t find other site that working fine, if you have multiple servers in a site, remove all servers and left only one server in the site (the idea is to make only one server/site), on Server Manager go to Site – Data Store, remove all Registered Databases entries and Registered Folders entries. Re-entry Register Database first until finish and continue to Register Folder. Make sure when you register first database, check if it created dsconnections.lst file on config-store\data folder. Otherwise, you might need to restart the server.

Those tips that I mentioned, fixed my issue. Thank you very much to those people in the Esri forum threads that give information and idea.

Meanwhile, I have some questions to Esri folks if might get chance to read my post,

  1. Why created dsconnections.lst file on both config-store and each server? I saw there were some inconsistency such as if I have multiple servers in a site, not all servers have identical file compare to each other and compare to config-store.
  2. Why created dsconnections.lst file on local if you are going to use the file on config-store folder?

Suggestion: if anytime we run validation using ArcCatalog and the result is green, why not copy the file from the local to config-store folder and to all servers member of the site (synchronization) and the other way from server manager. By that, all servers in the site and config-store folder will have identical file. Or to make it simple, why maintain critical configuration of a site in local server while you have a central location \config-store and \directories.

 

GOOD LUCK!!!

How to Install XGBoost on Windows


When you googled and landed to this blog, I could say you are struggling to install XGBoost on your Python. Anyway, My environment is Windows 7 and I use Spyder Python 3.4.4. I like this Spyder, it has so many modules available such as Panda, Numpy, Seaborn, Matplotlib, etc but no XGBoost. Let’s me give you some tips on how to install it:

  1. Go to this GitHub, https://github.com/dmlc/xgboost and download the folder python-package. Save it into your python environment. …\python-package\xgboost. it depends on where you have your python.exe. I have several python versions on my computer.
  2. Go to this site, http://www.picnet.com.au/blogs/guido/post/2016/09/22/xgboost-windows-x64-binaries-for-download/ and download  the latest libxgboost.dll. And save it to the same location as number 1.
  3. run python setup.py install.
  4. Once finished, open python console and type import xgboost to check if your installation ran successfully or not.

 

Good Luck!!!!!

How many time did your service been hit?


One day some one, could be your manager, customer or some one else, asked you if you could give them metric on how many time in a month or week your services have been hit. There are many ways to answer this and many tools available out there. Here, I would like to give you a free tool or you could say it as script where you can run and give an idea to your requester how many hits on your ArcGIS services.You can also modify this script to not only produce a csv file but also input into database, so everyone can access the data.

 

Good Luck,

 


#-------------------------------------------------------------------------------
# Name: HitStat.py
# Purpose: Gather hit statistics info in the last 24 hours. the statistics will be stored in DB and csv file
# Since there is limitation in Esri side how it pulls the data to max. 10,000 records from log file,
# We divide to an hour in 24 hours time frame. Even though each our has max 10,000 records at least
# it can show a close accurate data. The steps are: Pul each hour data into a temp csv and read the
# data from there and store in csv and database.
# Queries the logs and writes statistics on map service activity during the past 24 hours
# Sends email if no log data, indicating someone has changed ArcGIS Server Log settings
# The data is based on CODE = 100004 and 8521
#
# Author: mlou1_p
#
# Created: 04/13/2016
# Copyright: (c) mlou1_p 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------


# For Http calls
import httplib, urllib, json

# CSV Module
import csv

# Datetime module
import datetime

# For system tools
#import arcserver
import sys, time, arcserver, arcpy, re

# For sending email
import smtplib
import mimetypes
import email
import email.mime.application

# For reading passwords without echoing
import getpass


#Get the current date
now = datetime.datetime.now()

#Defines the entry point into the script
def main(argv=None):
# Print some info
print
print "This tool is a script that queries the ArcGIS Server logs and writes a report"
print " summarizing all map service draws within the past 24 hours."
print


# ########################################################################################################################################
#--- START OF VARIABLE--------------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################


# Ask for admin/publisher user name and password
#username = raw_input("Enter user name: ")
username = "ARCGISADMIN"
#password = getpass.getpass("Enter password: ")
password = "Abc123$"


# Ask for server name
#serverName = raw_input("Enter Server name: ")
serverName = "ARCGISSERVER01"
serverPort = 6080

# Connect to Oracle to put the data
##tbl = r"\\stlArcGISsvr\GIS_Data\data\ADM\GEOSPATIAL@GEORACLE.sde\GEOSPATIAL.HIT_STATISTICS" #turn off for testing

# Ask for text file path
filePath = "//stlArcGISsvr//d$//temp//HitStat//HitStat_" + str(now.year) + str(now.month) + str(now.day) + ".txt"
rawPath = "//stlArcGISsvr//d$//temp//HitStat//raw.csv"


# For email purposes
From = "noreply@esri.com"
Receivers = ["DL-DOOOH@esri.com"] # must be a list
EmailBody = "No Draw Time Log for DEV environment. Check ArcGIS Server Log Settings."

# For Testing Purpose please use this to look for specific date
#Date time start with
date_time = '04.12.2016 00:00:01'
pattern = '%m.%d.%Y %H:%M:%S'
##startTime = int(time.mktime(time.strptime(date_time, pattern))*1000)

startTime = int(round(time.time() * 1000)) # Current time and date


#millisecondsToQuery = 86400000 # One day
##millisecondsToQuery = 3600000 # One hour in millisecond
##n = 24 #1 hours X 24 = a day
millisecondsToQuery = 1800000 # half an hour in millisecond (30 minutes)
n = 48 # 30 min X 48 = a day


# ########################################################################################################################################
#--- END OF VARIABLE--------------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################



hitDict = {}
counter = 0
timeStamp = '%04d' % now.year + '%02d' % now.month + '%02d' % now.day


# Open text file and write header line
summaryFile = open(filePath, "w")
header = "Now;Service;Number of hits\n"

#Raw Data
rawData = open(rawPath,"w")
rawData.write("Service;Code"+"\n")


# Get a token
token = getToken(username, password, serverName, serverPort)
if token == "":
print "Could not generate a token with the username and password provided."
return

#insert cursor variables in Oracle
##fields = ["TIME", "SERVICE", "HITS"] #turn off for testing

#insert cursor
##insCur = arcpy.da.InsertCursor(tbl, fields) # turn off insCur for testing purposes



# Construct URL to query the logs
logQueryURL = "/arcgis/admin/logs/query"

##endTime = startTime - millisecondsToQuery

# Need these variables to calculate average draw time for an ExportMapImage call
mapDraws = 0
totalDrawTime = 0
timecount = 0

while (timecount < n):

if timecount <> 0:
rawData = open(rawPath,"a")

timecount = timecount + 1
print "time count = " +str(timecount)
xTime = millisecondsToQuery * timecount
#startTime = millisecondsToQuery + endTime
endTime = startTime - millisecondsToQuery
print "xTime = " + str(xTime)
print "Start Time = " + str(startTime)
print "End Time = " + str(endTime)


#logFilter = "{'services':'*','server':'*','machines':'*'}"
logFilter = "{'codes':[100004, 8521],'services':'*','server':'*','machines':'*'}" #Correct Code: 100004, changed to 12345 for test purposes

params = urllib.urlencode({'level': 'FINE', 'startTime': startTime, 'endTime': endTime, 'filter':logFilter, 'token': token, 'pageSize': 10000, 'f': 'json'})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request("POST", logQueryURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print "Error while querying logs."
return
else:
data = response.read()

# Check that data returned is not an error object
if not assertJsonSuccess(data):
print "Error returned by operation. " + data
else:
print "Operation completed successfully at " + str(timecount) + " hour"

# Deserialize response into Python object
dataObj = json.loads(data)
httpConn.close()

# Iterate over messages
for item in dataObj["logMessages"]:

# if item["message"] == "End ExportMapImage":
##elapsed = float(item["elapsed"])
keyCheck = item["source"]
code = str(item["code"])

msg = item["message"]
##print "Ori msg : " + msg

# If Code is 100004
if '8521' not in code:
rawData.write(keyCheck+ ";" + str(code) + "\n")
print "KeyCheck = " +keyCheck

#Input the result into temporary dictionary (hitDict)
if keyCheck in hitDict:
stats = hitDict[keyCheck]

# Add 1 to tally of hits
stats[0] += 1

else:
# Add key with one hit and total elapsed time
hitDict[keyCheck] = [1]


# If Code is 8521
else:
if 'services/' in msg:
if 'Server' in msg:

# Trim/Slice data to get Service Name

astrVerify = "arcgis/rest/services/"
a = msg.find(astrVerify)
msg = msg[a+len(astrVerify):]

bstrVerify = "Server"
b = msg.find(bstrVerify)
msg = msg[0:b+6]

# Replace the message that has second / with .
msg = re.sub(r'^((.*?/.*?){1})/', r'\1.', msg)

rawData.write(msg + ";" + str(code) + "\n")
print "KeyCheck = " +msg
keyCheck = msg



#Input the result into temporary dictionary (hitDict)
if keyCheck in hitDict:
stats = hitDict[keyCheck]

# Add 1 to tally of hits
stats[0] += 1

else:
# Add key with one hit and total elapsed time
hitDict[keyCheck] = [1]


startTime = endTime
rawData.close()



## #If no data, send email to GEOSPATIAL
## if hitDict == {}:
## EmailSubject = "No Draw Times found in log."
## for address in Receivers:
## EmailAttachments(address, From, EmailSubject, EmailBody)
##
## print "no draw times found!"



#Read the Raw Data
# Open text file and write header line
summaryFile = open(filePath, "w")
header = "Now;Service;Number of hits\n"
summaryFile.write(header)
print hitDict


# Read through dictionary and write totals into file
for key in sorted(hitDict.iterkeys()):

# Calculate average elapsed time
totalDraws = hitDict[key][0]

# Construct and write the comma-separated line
line = timeStamp +"," + key + "," + str(totalDraws) + "\n"

fields = ["TIME", "SERVICE", "HITS"]
##insCur.insertRow(( timeStamp, key, str(totalDraws) )) # comment out for testing


summaryFile.write(line)

summaryFile.close()
return








# ########################################################################################################################################
#--- DEFINED ALL FUNCTIONS----------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################



# A function to generate a token given username, password and the adminURL.
def getToken(username, password, serverName, serverPort):
# Token URL is typically http://server[:port]/arcgis/admin/generateToken
tokenURL = "/arcgis/admin/generateToken"

# URL-encode the token parameters
params = urllib.urlencode({'username': username, 'password': password, 'client': 'requestip', 'f': 'json'})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request("POST", tokenURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print "Error while fetching tokens from admin URL. Please check the URL and try again."
return
else:
data = response.read()
httpConn.close()

# Check that data returned is not an error object
if not assertJsonSuccess(data):
return

# Extract the toke from it
token = json.loads(data)
return token['token']





#A function that checks that the input JSON object
# is not an error object.
def assertJsonSuccess(data):
obj = json.loads(data)
if 'status' in obj and obj['status'] == "error":
print "Error: JSON object returns an error. " + str(obj)
return False
else:
return True



# A function to send email
def EmailAttachments(address, From, EmailSubject, EmailBody):
sender = From
receiver = address

# Create a text/plain message
msg = email.mime.Multipart.MIMEMultipart()
msg['Subject'] = EmailSubject
msg['From'] = sender
msg['To'] = receiver


# The main body is just another attachment
body = email.mime.Text.MIMEText(EmailBody)
msg.attach(body)

# Send the message via our own SMTP server, but don't include the
# envelope header.
smtpObj = smtplib.SMTP('mail.monsanto.com')
smtpObj.sendmail(sender, address, msg.as_string())
smtpObj.quit()



# Script start
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))</pre>
<pre>

The Headache of Password Caching in MXD file


Got headache of password caching in your mxd files?

If your company have policy to change account password frequently and has maximum bad password and your mxd document is getting data from an account that affect to it, most likely you will have problem locking the account. I have been researching the behavior of mxd document using a tool and found:

  • It caches password up to 3 times
  • It will cache password forever if you deleted a layer as the layer information still exists in the file, take a look this screenshot. This layer called Layer A After, it still exists in the file even I couldn’t see it from ArcMapHex

 

How to fix it?

Good question! There is ONLY one way that I know so far…it is…create a new mxd file! Or inject the encrypted password with latest one. Any comments?

A Request from one of my blog readers


Folks,

Some of you might come to my blog after googling around and as part of my mission to publish my notes is to help and share. Below here is a request came from Sepideh who is asking some of you or all of you via my blog to support his effort in creating a new Site on StackExchange.

Thank you.

 

 

Dear Muryadi,
As you might have already noticed, there aren’t much places on the net which professionally concentrate on remote sensing and photogrammetry and gather related researchers all over the world to exchange knowledge and improve the community. So I’ve proposed to build a new Q&A site for remote sensing and photogrammetry which is possible through the Area51 zone of StackExchange. (For further information, you may refer to the following links: FAQ and QA site.pdf)
In order to convince the stackexchange management team about the necessity of creating such a site, I need the support of the community. So regarding the close relationship between GIS and remote sensing would you please promote the idea on your website and ask your user to follow this link?
Remote Sensing and Photogrammetry Q&A site proposal
As you can see in the right hand side of the above page, we need 23 more questions with a score of 10 or more to jump to the next phase of the site creation process. Therefore, it would be appreciated if you could tell your users to take some minutes to judge the proposed questions by voting them up and down and commenting on them based on their relevance to the field of remote sensing and photogrammetry. (If you wish to upvote, please upvote the questions that have less than 10 scores not the ones that have been upvotted more than 10 times. At this step upvoting under 10 score questions is even more important than following. However, following is still necessary)
Also could you please ask them to add at least one expert question to the list if you have enough time? (This is needed to decide about the content of the future site)
King Regards,
Links:
Area51 zone : http://goo.gl/yYmjAv
StackExchange : http://goo.gl/MUwsne
FAQ : http://goo.gl/B5BeLa
QA site.pdf : https://goo.gl/br2Pm3
stackexchange management team :http://goo.gl/bVsbyD
Remote Sensing and Photogrammetry Q&A site proposal : http://goo.gl/z3jRfN
—————————————————————-
Sepideh Abadpour
M.Sc. Student in Remote Sensing
University of Tehran, College of Engineering,
School of Surveying and Geospatial Engineering
Email Address1: sepidehabadpour@ut.ac.ir
Email Address2: abadpours@gmail.com

Collect All Service Properties Information in Site


You can find your service properties information from ArcGIS server manager or admin but how about if you want to see all of your services’ properties? you can run a script and see from there. I found this script was really useful when i wanted to check if any publisher published their service without accepting default value, for example: change minimum instances or maximum instances or maximum idle time or different cluster. Or with a little modification, you can query some other information.

Hopefully you find this script is useful for you.

Cheers…

 

#-------------------------------------------------------------------------------
# Name: List_Svc_properties.py
# Purpose: List All Started Services and their properties
#
# This script could be scheduled to run at a regular interval.
#
# Author: Muryadi Oey
#
# Created: 03/11/2016
# Copyright: (c) muryadioey 2016
# Licence: &lt;your licence&gt;
#-------------------------------------------------------------------------------

# For Http calls
import httplib, urllib,json,urllib2

# For system tools
import sys, datetime

# For reading passwords without echoing
import getpass

#Get the current date
now = datetime.datetime.now()

# Defines the entry point into the script
def main(argv=None):

# ##########################################################################################################################
# Start of Variables
# ##########################################################################################################################

# Server name
##serverName = raw_input(&quot;Enter server name: &quot;)
serverName = 'SERVER01'

# Admin/publisher user name and password
## username = raw_input(&quot;Enter user name: &quot;)
## password = getpass.getpass(&quot;Enter password: &quot;)
username = 'ARCGISADMIN'
password = 'passwordadmin'

# Log file location
filePath = r'\\server01\d$\temp\Svc_Properties.txt'
doc = open(filePath, 'w')
header = &quot;Server;Service;Status;MinIns;MaxIns;MaxIdle;MaxStart;MaxUsage;MaxWait;IsolationLevel;Cluster&quot;
doc.write(header +&quot;\n&quot;)

# ###########################################################################################################################
# End of Variables
# ###########################################################################################################################
# Print some info
print
print &quot;This script is to collect all services' information.&quot;
serverPort = 6080
print

# Create a list to hold folder names
folderList = []

# Create a list to hold stopped/started services
targetList = []

# Get a token
token = getToken(username, password, serverName, serverPort,doc)
if token is None:
print &quot;Could not generate a token with the username and password provided.&quot;
doc.write(&quot;\nCould not generate a token with the username and password provided.&quot; +&quot;\n&quot;)
doc.close()
return

folderList = getCatalog(token,serverName,serverPort,doc)

for folder in folderList:
count = targetList.__len__()
i =0
folderName = folder
print &quot;Processing folder : &quot; + folderName
#doc.write(&quot;\n&quot;+ &quot;Processing folder : &quot; + folderName + &quot;\n&quot;)
while(i &lt; count):
targetList.remove(targetList.__getitem__(0))
i = i +1

# Construct URL to read folder
if folder == &quot;ROOT&quot;:
folder = &quot;&quot;
else:
folder += &quot;/&quot;

folderURL = &quot;/arcgis/admin/services/&quot; + folder

# This request only needs the token and the response formatting parameter
params = urllib.urlencode({'token': token, 'f': 'json'})

headers = {&quot;Content-type&quot;: &quot;application/x-www-form-urlencoded&quot;, &quot;Accept&quot;: &quot;text/plain&quot;}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request(&quot;POST&quot;, folderURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print &quot;Could not read folder information.&quot;
doc.write(&quot;\n&quot; + &quot;Could not read folder information.&quot; +&quot;\n&quot;)
return
else:
data = response.read()

# Check that data returned is not an error object
if not assertJsonSuccess(data,doc):
print &quot;Error when reading folder information. &quot; + str(data)
#doc.write(&quot;\n&quot; + &quot;Error when reading folder information. &quot; + str(data)+&quot;\n&quot;)
else:
print &quot;Processed folder information successfully. Now processing services...&quot;
#doc.write(&quot;Processed folder information successfully. Now processing services...&quot; +&quot;\n&quot;)
print

# Deserialize response into Python object
dataObj = json.loads(data)
httpConn.close()

counter = 0

# Loop through each service in the folder and stop or start it
for item in dataObj['services']:

fullSvcName = item['serviceName'] + &quot;.&quot; + item['type']

# Construct URL to stop or start service, then make the request
statusURL = &quot;/arcgis/admin/services/&quot; + folder + fullSvcName + &quot;/status&quot;
httpConn.request(&quot;POST&quot;, statusURL, params, headers)
# Read status response
statusResponse = httpConn.getresponse()
if (statusResponse.status != 200):
httpConn.close()
print &quot;Error while checking status for &quot; + fullSvcName
doc.write(&quot;\n&quot; + &quot;Error while checking status for &quot; + fullSvcName +&quot;\n&quot;)
return
else:
statusData = statusResponse.read()

# Check that data returned is not an error object
if not assertJsonSuccess(statusData,doc):
print &quot;Error returned when retrieving status information for &quot; + fullSvcName + &quot;.&quot;
doc.write(&quot;\n&quot; + &quot;Error returned when retrieving status information for &quot; + fullSvcName + &quot;.&quot; +&quot;\n&quot;)
print str(statusData)
doc.write(&quot;\n&quot; + str(statusData) +&quot;\n&quot;)

else:

statusDataObj = json.loads(statusData)
status = statusDataObj['realTimeState']

minInstURL = &quot;/arcgis/admin/services/&quot; + folder + fullSvcName
httpConn.request(&quot;POST&quot;, minInstURL, params, headers)

# Collect all services information, you can also query any information available in Service properties
# Read status response
minInstResponse = httpConn.getresponse()
minInstData = minInstResponse.read()
minInstDataObj = json.loads(minInstData)
minIns = minInstDataObj['minInstancesPerNode']
maxIns = minInstDataObj['maxInstancesPerNode']
maxIdle = minInstDataObj['maxIdleTime']
maxStr = minInstDataObj['maxStartupTime']
maxUsg = minInstDataObj['maxUsageTime']
maxWait = minInstDataObj['maxWaitTime']
isoLvl = minInstDataObj['isolationLevel']
cluster = minInstDataObj['clusterName']
print (serverName + ';'+ str( fullSvcName) + ';'+ str(status) + ';'+ str(minIns) +';' + str(maxIns) +';' +str(maxIdle) +';' +str(maxStr) +';' +str(maxUsg) +';' +str(maxWait) +';' +str(isoLvl) +';' +str(cluster) )
doc.write(serverName + ';'+ str( fullSvcName) + ';'+ str(status) +';'+ str(minIns) +';' + str(maxIns) +';' +str(maxIdle) +';' +str(maxStr) +';' +str(maxUsg) +';' +str(maxWait) +';' +str(isoLvl) +';' +str(cluster) +'\n' )
httpConn.close()

print
doc.close()
return

def getCatalog(token,server,port,doc):
baseUrl = &quot;http://{}:{}/arcgis/admin/services&quot;.format(server, port)
folderNameList = []
catalog = json.load(urllib2.urlopen(baseUrl + &quot;/&quot; + &quot;?f=json&amp;token=&quot; + token))
print ' List of Folders :'
#doc.write(&quot; List of Folders :&quot; +&quot;\n&quot;)
print '\tROOT'
#doc.write(&quot;\tROOT&quot; +&quot;\n&quot;)
folderNameList.append(&quot;ROOT&quot;)
if &quot;error&quot; in catalog: return
folders = catalog['folders']
for folderName in folders:
folderNameList.append(folderName)
print '\t'+folderName
#doc.write(&quot;\t&quot;+folderName +&quot;\n&quot;)
if &quot;error&quot; in catalog: return
else: return folderNameList
# A function to generate a token given username, password and the adminURL.
def getToken(username, password, serverName, serverPort,doc):
# Token URL is typically http://server[:port]/arcgis/admin/generateToken
tokenURL = &quot;/arcgis/admin/generateToken&quot;

params = urllib.urlencode({'username': username, 'password': password, 'client': 'requestip', 'f': 'json'})

headers = {&quot;Content-type&quot;: &quot;application/x-www-form-urlencoded&quot;, &quot;Accept&quot;: &quot;text/plain&quot;}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request(&quot;POST&quot;, tokenURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print &quot;Error while fetching tokens from admin URL. Please check the URL and try again.&quot;
doc.write(&quot;\n&quot; + &quot;Error while fetching tokens from admin URL. Please check the URL and try again.&quot; +&quot;\n&quot;)
return
else:
data = response.read()
httpConn.close()

# Check that data returned is not an error object
if not assertJsonSuccess(data,doc):
return

# Extract the token from it
token = json.loads(data)
return token['token']
# A function that checks that the input JSON object
# is not an error object.
def assertJsonSuccess(data,doc):
obj = json.loads(data)
if 'status' in obj and obj['status'] == &quot;error&quot;:
print &quot;Error: JSON object returns an error. &quot; + str(obj)
#doc.write(&quot;\n&quot; + &quot;Error: JSON object returns an error. &quot; + str(obj) +&quot;\n&quot;)
return False
else:
return True
# Script start
if __name__ == &quot;__main__&quot;:
sys.exit(main(sys.argv[1:]))

Shape Integrity Error


Got this error, Shape Integrity Error? after for a while your mxd file was fine and suddenly, it popped up the error? or you couldn’t republish your mxd file and when you opened your data in ArcMap and sorted the data, you got the error?

Shape Integrity Error is related to your data, whether it is corrupted or it has different geometry type (SDO_gTYPE).

In my case, I am using Oracle spatial, some data has been loaded without being checked. This Oracle site has good information about SDO_GEOMETRY object type,

SDO_GEOMETRY Object Type

Here are some queries that you can use to check your data,

For example: your table/view name is World_Countries that has a column, Shape with SDO_Geometry data type. So to query all SDO_Geometry info

 
select a.Shape , a.Shape.sdo_srid, a.Shape.sdo_gtype,
a.Shape.sdo_point, a.Shape.sdo_elem_info, a.Shape.sdo_ordinates from World_Countries a;

 

from there you can filter your data to find if the data have different geometry type or SRID or etc.

 

Hopefully this post can give you idea to solve your error mystery 🙂