Hi,
could you post the error message too?
David
Hi David
The java error returned is;
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://<fmeserver>/fmedatastreaming/Dynamic/ejson2wkt.fmw?
The logfile for the translation shows errors when it tries to open the default dataset from the original translation instead of the file I'm trying to upload in the java code.
35 INFORM 0 0.1 2013-05-13 16:38:34 915400 Opening the ESRIJSON reader with source dataset 'D:/stuv/fme_stuff/ejson/lgas.json' 36 ERROR 0 0.1 2013-05-13 16:38:34 925250 A JSON syntax error was found at line 1, column 0 37 ERROR 0 0.1 2013-05-13 16:38:34 925251 The JSON data is incomplete: Unexpectedly encountered the end of JSON data 38 ERROR 0 0.1 2013-05-13 16:38:34 246009 A fatal error has occurred. Check the logfile above for details
The job request on the server does not contain the source and destination dataset parameters I'm trying to pass in the code.
I'm trying to structure the call in the same fashion as that shown in the html on the 'developer information' section for the translation on server.
Hi,
it's difficult to tell since we only know part of your process, but I would start by using something like Fiddler or Firebug to intercept and check the http calls between your Java code and FME Server.
You could also intercept the http calls when executing your workspace from the FME Server GUI and compare those to the ones you generate.
David
Hi All
Here's where I'm at. I'm still trying to upload a source file to FME Server 2013. Currently the translation runs but errors because it can't read the source file. If I look in the directory on server where the file should upload to It's not there.
I've used Firebug to look at the message body for the successful upload using the generated html code and compared it to the message body sent from my java code for the file upload. Appears the same.
My code uses the URL generated from the developer detail on server which is
http://localhost:1234/fmedatastreaming/Dynamic/ejson2wkt.fmw?"
+ "&DestDataset_TEXTLINE=WKT.txt&SourceDataset_ESRIJSON=" + f.getName());
I've tried adding /fmeserver/invoke to the path as Pascal suggested but that gave me a HTTP response code: 401.
What security settings on server should I check?
Hi,
There are two sections in the developper info:
Direct Url Example
In this case, I think you have to provide the file to upload as the body of the POST request (not multipart) and all the published parameters should be provided as parameters in the URL as you did. Also, I think the "Source dataset to receive HTTP content" has to be correctly set in the Data Streaming service properties when publishing the workspace to FME Server.
Form Example
This is using the fmeserver/invoke/datastreaming path. It expect to receive a POST request with a multipart body (as I understand you did in your example). It will first upload the data using the upload data service and then fires the translation. There are some FMEPedia articles documenting that way of doing (
http://fmepedia.safe.com/articles/How_To/Direct-Upload-and-Run-with-FME-Server)
In this case, the security might be based on the capacity of a user to access the webui, but I am not certain. I know that in my case, the following code worked. It uses Apache HttpComponents library to ease the http request building part.
Pascal
====================
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
public class ServiceTest
{
@Test
public void Test() throws IOException
{
HttpHost host_;
BasicHttpContext context_;
DefaultHttpClient httpClient_;
host_ = new HttpHost("localhost", 8080, "http");
// Setup basic Authentication
httpClient_ = new DefaultHttpClient();
httpClient_.getCredentialsProvider().setCredentials(new AuthScope(host_.getHostName(), host_.getPort()),
new UsernamePasswordCredentials("user", "user"));
// Setup preemptive authentication
AuthCache authCache = new BasicAuthCache();
authCache.put(host_, new BasicScheme());
context_ = new BasicHttpContext();
context_.setAttribute(ClientContext.AUTH_CACHE, authCache);
// Get test input file
File file = new File("C:\\\\FME Data\\\\Data\\\\Airport\\\\airport.qlf");
// Build the URL for DataStreaming service invoke from webui
HttpPost request = new HttpPost("/fmeserver/invoke/fmedatastreaming/Samples/easyTranslator.fmw");
MultipartEntity entity = new MultipartEntity();
// Set file name
Charset charset = Charset.forName("UTF-8");
entity.addPart("SourceDataset_GENERIC", new StringBody("airport.qlf", charset));
// Add file content to body
FileBody fileBody = new FileBody(file);
entity.addPart("OPT_FileUpload", fileBody);
request.setEntity(entity);
// Let's do the request
HttpResponse response = httpClient_.execute(host_, request, context_);
}
}