Skip to main content
Question

FMEServer.init Javascript fails to define server


Hey Everyone,

I'm trying to do some javascript work with FME Server. I can't seem to connect to my server that runs FME Server. I have the FMEServer.init method set up window.onload but I get the attached error. The onload code is below too, the FMEServer.init portion is near the bottom.

 

0684Q00000ArAeFQAV.jpg

 

window.onload = function()
{
debugger;
require([
"esri/map""esri/toolbars/draw",
"esri/graphic""esri/geometry/webMercatorUtils",
"esri/symbols/SimpleLineSymbol""esri/symbols/SimpleFillSymbol",
"dojo/_base/Color""dojo/dom""dojo/on""dojo/domReady!"
], function(
Map, Draw,
Graphic, webMercatorUtils,
SimpleLineSymbol, SimpleFillSymbol,
Color, dom, on
)
{
map = new Map("mapDiv",
{
basemap: "hybrid"//Select the basemap
center: [-155.11416670.27], //Enter the coordinates to center the map
zoom: 7//Set the default zoom
minZoom: 4,//Set the minimum zoom level
smartNavigation: false
});

map.on("load"function()
{
toolbar = new Draw(map);

dojo.connect(toolbar, "onDrawEnd", addToMap);

on(dom.byId("draw"), "click", drawPolyline);
on(dom.byId("reset"), "click", drawReset);
});

function addToMap(geometry)
{
var symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_NULL,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([25500]), 2
),
new Color([25525500.25])
);
geometry = webMercatorUtils.webMercatorToGeographic(geometry);
var graphic = new Graphic(geometry, symbol);
map.graphics.clear();
map.graphics.add(graphic);
toolbar.deactivate(Draw.POLYLINE);
storedGeometry = geometry.paths[0];
}

function drawPolyline()
{
drawReset();
toolbar.activate(esri.toolbars.Draw.POLYLINE);


}

function drawReset()
{
toolbar.deactivate(esri.toolbars.Draw.POLYLINE);
map.graphics.clear();
}
});
debugger;
FMEServer.init(
{

server: "http://hocwapp0053"//Update with your Server hostname - on FME training machines this is http://fmetraining
token: "7a2fce751ef10468fe6952670ccebcaa449edc39" //Update to your fmetoken

});
};

10 replies

siennaatsafe
Safer
Forum|alt.badge.img+10

Hi @fme_noob,

In your code somewhere are you initializing the FME JavaScript API?

It should look something like this

<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>

  • Author
  • April 15, 2020
siennaatsafe wrote:

Hi @fme_noob,

In your code somewhere are you initializing the FME JavaScript API?

It should look something like this

<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>

Hey @siennaatsafe thanks for the repsonse. I do have that bit in my html head

 

<head>
<title>Example</title>
<!-- Styles for example -->
<link rel="stylesheet" href="http://playground.fmeserver.com/css/FMEServerExamples.css" type="text/css" />
<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>
<!-- The following are Required for ArcGIS Maps -->
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css" />
<script type="text/javascript" src="http://js.arcgis.com/3.8/"></script>
<!-- <script type="text/javascript" src="jquery-3.3.1.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="Javascript/Alaskajs.js"></script>
</head>

siennaatsafe
Safer
Forum|alt.badge.img+10
fme_noob wrote:

Hey @siennaatsafe thanks for the repsonse. I do have that bit in my html head

 

<head>
<title>Example</title>
<!-- Styles for example -->
<link rel="stylesheet" href="http://playground.fmeserver.com/css/FMEServerExamples.css" type="text/css" />
<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>
<!-- The following are Required for ArcGIS Maps -->
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css" />
<script type="text/javascript" src="http://js.arcgis.com/3.8/"></script>
<!-- <script type="text/javascript" src="jquery-3.3.1.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="Javascript/Alaskajs.js"></script>
</head>

Hi @fme_noob,

Could you put all your code into something like JS fiddle so I can take a look? https://jsfiddle.net/


  • Author
  • April 15, 2020
siennaatsafe wrote:

Hi @fme_noob,

Could you put all your code into something like JS fiddle so I can take a look? https://jsfiddle.net/

@siennaatsafe I've copy/pasted it in jsfiddle. IT partially won't work because my html/js file are in my own folder structure atm: https://jsfiddle.net/cmclellan/8fynkcje/


siennaatsafe
Safer
Forum|alt.badge.img+10
fme_noob wrote:

@siennaatsafe I've copy/pasted it in jsfiddle. IT partially won't work because my html/js file are in my own folder structure atm: https://jsfiddle.net/cmclellan/8fynkcje/

Hi @fme_noob,

When I have your code like this I can get a response back from the Server. https://jsfiddle.net/90jrdgzt/3/


  • Author
  • April 15, 2020
siennaatsafe wrote:

Hi @fme_noob,

When I have your code like this I can get a response back from the Server. https://jsfiddle.net/90jrdgzt/3/

My issue seems to be when I try to replace the server with my own company server thats hosting my FMEServer

You have https://bluesky-safe-software.fmecloud.com/ on line 72 of the javascript but I have to change it to my own. Are there any guidelines to accomplishing this?

 


siennaatsafe
Safer
Forum|alt.badge.img+10
fme_noob wrote:

My issue seems to be when I try to replace the server with my own company server thats hosting my FMEServer

You have https://bluesky-safe-software.fmecloud.com/ on line 72 of the javascript but I have to change it to my own. Are there any guidelines to accomplishing this?

 

I think JS fiddle doesn't like servers with http. However, this code on a normal server should work with http or https. How are you hosting your code? Could you try something like the python example here? https://s3.amazonaws.com/gitbook/Server-REST-API-UC20/FMESERVER_RESTAPI8Session2/8.2.HostingWebApplications.html


  • Author
  • April 16, 2020
siennaatsafe wrote:

I think JS fiddle doesn't like servers with http. However, this code on a normal server should work with http or https. How are you hosting your code? Could you try something like the python example here? https://s3.amazonaws.com/gitbook/Server-REST-API-UC20/FMESERVER_RESTAPI8Session2/8.2.HostingWebApplications.html

Hey @siennaatsafe

Since this is an internal tool at my company, I wasn't sure what if any hosting I needed to perform. Does Safe have any on-prem servers and has anyone tried the FMEServer.init function in that situation?


siennaatsafe
Safer
Forum|alt.badge.img+10
fme_noob wrote:

Hey @siennaatsafe

Since this is an internal tool at my company, I wasn't sure what if any hosting I needed to perform. Does Safe have any on-prem servers and has anyone tried the FMEServer.init function in that situation?

Hi @fme_noob,

I've tested these with the Python server which creates a local web server for testing and it worked for me. https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server


  • Author
  • April 16, 2020
siennaatsafe wrote:

Hi @fme_noob,

I've tested these with the Python server which creates a local web server for testing and it worked for me. https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

Hey @siennaatsafe

So I logged onto my server and used the python method to set up a http://localhost:8000. I ran the html through the local host and for some reason my server is still undefined on the init function.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings