uProduce API

203 views
Skip to first unread message

Ernie Broennle

unread,
Nov 20, 2023, 3:44:23 PM11/20/23
to xmpie...@googlegroups.com
I'm attempting to use both the createnew and replace methods in the uProduce api:
http://10.0.2.33/XmpieWSAPI/DataSource_SSP.asmx?op=CreateNew
http://10.0.2.33/XmpieWSAPI/DataSource_SSP.asmx?op=Replace

The attempt is to upload a csv file. I believe I have all the parameters correct in my SOAP request with the exception of the connection string information. I see the examples in the SDK but those are for mdb files. I'm sure this is some kind of ODBC connection string, but i can't figure it out. Can you point me in the right direction?

Thanks,
Ernie

couch

unread,
Nov 20, 2023, 3:51:16 PM11/20/23
to XMPie Interest Group
I'd recommend you to use the new REST API instead of WSAPI, but anyhow, I have used this code before:

           //set some variables
            string username = "xxxx";
            string password = "yyyyy";
            string remotedatafile = @"c:\temp\contacts2.csv";
            int bufferSizeInBytes = 128;
            string docID = "222";

            //do the file upload to temp storage
            xmp_ts.TempStorage_SSP tempStorage = new xmp_ts.TempStorage_SSP();
            string tempFolder = tempStorage.CreateFolder(username, password);
            string fileToken = tempStorage.AddFileToFolder(username, password, tempFolder, System.IO.Path.GetFileName(remotedatafile));
            System.IO.FileStream fs = new System.IO.FileStream(remotedatafile, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            int numToRead = (int)fs.Length;
            int bytesRead = 0;
            byte[] buffer = new byte[bufferSizeInBytes];
            while (numToRead > 0)
            {
                bytesRead = fs.Read(buffer, 0, bufferSizeInBytes);
                if (bytesRead > 0)
                {
                    bool ret = tempStorage.AppendFileBinaryStream(username, password, fileToken, buffer);
                    numToRead -= bytesRead;
                }
            }

            //create the recipient info
            xmp_jt.RecipientsInfo ri = new xmp_jt.RecipientsInfo();
            ri.m_Filter = System.IO.Path.GetFileName(fileToken);
            ri.m_FilterType = 3;

            //create the connection string
            xmp_jt.Connection conn = new xmp_jt.Connection();
            conn.m_ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.IO.Path.GetDirectoryName(fileToken) + ";Extended Properties=text;";
            conn.m_AdditionalInfo = System.IO.Path.GetFileName(fileToken) + "@,@,";
            conn.m_Type = "TXT";

            //create job ticket
            xmp_jt.JobTicket_SSP jt = new xmp_jt.JobTicket_SSP();
            string jtid = jt.CreateNewTicketForDocument(username, password, docID, "", false);
            jt.SetOutputInfo(username, password, jtid, "PDFO", 1, null, null, null);
            jt.SetJobType(username, password, jtid, "PRINT");
            jt.SetRI(username, password, jtid, ri, conn);

            //submit the job
            xmp_p.Production_SSP prod = new xmp_p.Production_SSP();
            string jobid = prod.SubmitJob(username, password, jtid, "0", null, null);

Ernie Broennle

unread,
Nov 20, 2023, 5:24:18 PM11/20/23
to xmpie...@googlegroups.com
I switched to the REST API which is definitely easier (thank you), i just had a number of things built in WSAPI and thought this would be 'easy'. Anyhow, turns out the issue wasn't the connection string but a dumb reference to the file being uploaded. Was referencing the local file system and not having the file on the server. Got to that conclusion though from following your process of tempstorage.

Thanks,
E

--
You received this message because you are subscribed to the Google Groups "XMPie Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xmpie-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xmpie-users/d1408f12-0b07-4aeb-ba66-52f7138fe5f9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages