C# Fax Jobsubmit
I'm trying to create a prototype using this API to send fax messages. I'm using the samples at https://apiforums.easylink.com/content/c-sample-jobsubmit-sms-options-single-recipient as a reference.
Getting an exception with the message - The request failed with an empty response. Here is my code below
public static void SendFaxCopied()
{
//JobSubmitRequest Fax
// setup EMsgAPI object - EM
ELJobSubmit.JobSubmitService EM = new ELJobSubmit.JobSubmitService();
// setup Authentication objects
ELJobSubmit.RequestAuthentication reqAuth = new ELJobSubmit.RequestAuthentication();
ELJobSubmit.XDDSAuthType XDDSAuth = new ELJobSubmit.XDDSAuthType();
ELJobSubmit.UIDType uid = new ELJobSubmit.UIDType();
// init Authentication objects
XDDSAuth.Password = "password";
uid.Value = "username";
XDDSAuth.RequesterID = uid;
//Add to send to Fax2Mail
//XDDSAuth.RequesterID.aliasType = "M2F";
reqAuth.Item = XDDSAuth;
// Setup MessageObject
ELJobSubmit.MessageType[] JS_Message = new ELJobSubmit.MessageType[1];
JS_Message[0] = new ELJobSubmit.MessageType();
// Setup JobOptions - CREF, Billing Code, FAX
ELJobSubmit.JobOptionsType JS_JobOptions = new ELJobSubmit.JobOptionsType();
ELJobSubmit.FaxOptionsType JS_FaxOptions = new ELJobSubmit.FaxOptionsType();
// Set Start and End Time
//DateTime StartDateValue = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, dateTimePicker1.Value.Hour, dateTimePicker1.Value.Minute, 0, dateTimePicker1.Value.Kind);
//DateTime EndDateValue = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, dateTimePicker2.Value.Hour, dateTimePicker2.Value.Minute, 0, dateTimePicker2.Value.Kind);
DateTime StartDateValue = new DateTime();
StartDateValue = DateTime.Now.AddHours(1);
DateTime EndDateValue = new DateTime();
EndDateValue = DateTime.Now.AddHours(2);
ELJobSubmit.DeliveryType ScheduledDelivery = new ELJobSubmit.DeliveryType();
ScheduledDelivery.Schedule = ELJobSubmit.ScheduleType.scheduled;
ScheduledDelivery.ScheduleSpecified = true;
ScheduledDelivery.StartTimeSpecified = true;
ScheduledDelivery.StopTimeSpecified = true;
ScheduledDelivery.StartTime = StartDateValue;
ScheduledDelivery.StopTime = EndDateValue;
//JS_JobOptions.Delivery = ScheduledDelivery;
// Set FaxOptions
//JS_FaxOptions.FaxMode = ELJobSubmit.FaxModeType.fine;
//JS_FaxOptions.FaxModeSpecified = true;
// Set Retry Algo
JS_FaxOptions.DeliveryRetryPattern = "11";
ELJobSubmit.FaxCoversheetOptionType CoverSheet = new ELJobSubmit.FaxCoversheetOptionType();
CoverSheet.UseCoversheet = ELJobSubmit.YesNo.yes;
//Specify a cover sheet
//CoverSheet.CoversheetName = "f2m_default";
ELJobSubmit.EncodableStringType CS_To = new ELJobSubmit.EncodableStringType();
CS_To.Value = "Tom";
CoverSheet.CoversheetTo = CS_To;
ELJobSubmit.EncodableStringType CS_Attn = new ELJobSubmit.EncodableStringType();
CS_Attn.Value = "Mr. Smith";
CoverSheet.CoversheetAttn = CS_Attn;
ELJobSubmit.EncodableStringType CS_From = new ELJobSubmit.EncodableStringType();
CS_From.Value = "EasyLink";
CoverSheet.CoversheetFrom = CS_From;
JS_FaxOptions.FaxCoversheet = CoverSheet;
//// Set PilotLine
ELJobSubmit.FaxPilotlineOptionType PilotLine = new ELJobSubmit.FaxPilotlineOptionType();
PilotLine.PilotlineStyle = ELJobSubmit.PilotlineStyleType.none;
PilotLine.PilotlineStyleSpecified = true;
PilotLine.PilotlineText = "PILOTLINETEXT";
//JS_FaxOptions.Pilotline = PilotLine;
//// Set Orientation
//JS_FaxOptions.PageOrientation = ELJobSubmit.PageOrientationType.landscape;
//JS_FaxOptions.PageOrientationSpecified = true;
// Set JobOptions as FaxOptions
JS_JobOptions.FaxOptions = JS_FaxOptions;
// Set Message Object
JS_Message[0].JobOptions = JS_JobOptions;
// Free Objects
JS_JobOptions = null;
JS_FaxOptions = null;
// Setup Documents
ELJobSubmit.DocumentType[] JS_Documents = new ELJobSubmit.DocumentType[2];
JS_Documents[0] = new ELJobSubmit.DocumentType();
// Setup reusable variables for the document
ELJobSubmit.DocDataType DocData = new ELJobSubmit.DocDataType();
string File;
//// Setup Document 3 - Text
DocData = new ELJobSubmit.DocDataType();
File = ReadAndEncodedFile("This is where the contents of the file show go", true);
DocData.format = ELJobSubmit.DocEncodingFormat.text;
DocData.Value = "This is a test document";
JS_Documents[0].Item = DocData;
JS_Documents[0].Filename = new ELJobSubmit.EncodableStringType { Value = "text.txt" };
JS_Documents[0].DocType = "text";
JS_Documents[0].ItemElementName = ELJobSubmit.ItemChoiceType.DocData;
JS_Documents[0].@ref = "Doc1";
DocData = null;
// Setup Content
ELJobSubmit.ContentsType EM_Content = new ELJobSubmit.ContentsType();
ELJobSubmit.ContentPartType[] JS_Content = new ELJobSubmit.ContentPartType[1];
JS_Content[0] = new ELJobSubmit.ContentPartType();
//JS_Content[1] = new ELJobSubmit.ContentPartType();
// Setup references to documents
JS_Content[0].Item = "Doc1";
JS_Content[0].Treatment = ELJobSubmit.TreatmentType.body;
JS_Content[0].TreatmentSpecified = true;
// Setup List Object
ELJobSubmit.FaxType[] lists = new ELJobSubmit.FaxType[1];
lists[0] = new ELJobSubmit.FaxType();
lists[0].From = new ELJobSubmit.EncodableStringType() { Value = "3212131243" };
lists[0].Phone = "8008082904";
JS_Message[0].Destinations = lists;
//EM_Content.DynamicContent = JS_Content;
EM_Content.Part = JS_Content;
JS_Message[0].Contents = EM_Content;
JS_Message[0].MessageId = System.Environment.MachineName + DateTime.Now;
JS_Content = null;
// Everything is Setup Prepare to Launch Job
// Setup Request and JobSubmitRequest object
ELJobSubmit.Request Request = new ELJobSubmit.Request();
ELJobSubmit.Response Response = new ELJobSubmit.Response();
ELJobSubmit.JobSubmitRequest JS_Request = new ELJobSubmit.JobSubmitRequest();
ELJobSubmit.JobSubmitResult JS_Result = new ELJobSubmit.JobSubmitResult();
// Setup Proxy server and EMsgAPIConnect URL for posting data
Set_Server_and_Proxy(EM);
// Setup Reqeust Object
Request.ReceiverKey = EM.Url;
Request.Authentication = reqAuth;
Request.RequestID = "RequestID";
JS_Request.SubmitId = "SubmitId";
// Assign Reqeust and Response objects to EM Object
EM.RequestValue = Request;
EM.ResponseValue = Response;
JS_Request.Message = JS_Message;
JS_Request.DocumentSet = JS_Documents;
try
{
JS_Result = EM.JobSubmit(JS_Request);
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
System.Console.Read();
return;
}
//if (JS_Result != null)
//{
// if (JS_Result.Status.StatusCode != null)
// {
// string JobNumber;
// JobNumber = JS_Result.MessageResult[0].JobId.XDN + ":" + JS_Result.MessageResult[0].JobId.MRN;
// txtJobNumber.Text = JobNumber;
// }
//}
string emfilename = "emresponse.xml";
string resfilename = "result.xml";
//string reqfilename = "request.xml";
try
{
//This will output the response, result and request(if uncommented) to XML files in the
//installed directory. This can be very usefull for debugging or ir help is requested from
//the EMAPI support team
serializeResult(emfilename, EM.ResponseValue);
serializeResult(resfilename, JS_Result);
//serializeResult(reqfilename, JS_Request);
}
catch (IOException io_error)
{
MessageBox.Show("Error - " + io_error, "Error", MessageBoxButtons.OK);
}
}
private static void Set_Server_and_Proxy(System.Web.Services.Protocols.SoapHttpClientProtocol EM)
{
EM.Url = "https://test2messaging.easylink.com/soap/sync"; //the EasyLink URL to submit to.
}
Comments
-
None of the services call I make seem to be working. I get the same error - The request failed with an empty response.
Here's my code for a call to Authenticate
private static void SendAuthenticate()
{
// Create service reference
var authService = new ELAuthenticate.AuthenticateService();
// Setup auth
var xDDSAuth = new ELAuthenticate.XDDSAuthType()
{
RequesterID = new ELAuthenticate.UIDType()
{
Value = "userid"
},
Password = "password"
};
var requestAuth = new ELAuthenticate.RequestAuthentication
{
Item = xDDSAuth
};
var request = new ELAuthenticate.Request()
{
Authentication = requestAuth,
ReceiverKey = "https://test2messaging.easylink.com/soap/sync"
};
authService.RequestValue = request;
var authRequest = new ELAuthenticate.AuthenticateRequest();
var submit_result = authService.Authenticate(authRequest);
}
0 -
Click on the URL and make sure you see the API message in your browser.
https://test2messaging.easylink.com/soap/sync
If you do, step through your code and look at both sides of EM.JobSubmit(JS_Request).
Some of the code is missing from the bottom, I do not see the ReadAndEncodedFile function, but it may just be cropped off in your paste.
0 -
Yes, I do see the API message in the browser. The thing is, this code was working a few months ago when we were first evaluating the product. Picked it up again yesterday and now it's not working. I've been digging around to see if I my have changed something accidentally.
The ReadAndEncodedFile method comes from this other forum link C# Ssample Helper Functions. This is what it looks like.
private static string ReadAndEncodedFile(string FullFileName)
{
string return_value;
return_value = ReadAndEncodedFile(FullFileName, true);
return return_value;
}
private static string ReadAndEncodedFile(string FullFileName, bool bBase64Encode)
{
// read the file
System.IO.FileStream inFile;
byte[] binaryData;
try
{
inFile = new System.IO.FileStream(FullFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
binaryData = new byte[inFile.Length];
long bytesRead = inFile.Read(binaryData, 0, System.Convert.ToInt32(inFile.Length));
inFile.Close();
}
catch (System.Exception exp)
{
// Error creating stream or reading from it.
System.Console.WriteLine("{0}", exp.Message);
return "FAIL";
}
string base64String;
if (bBase64Encode)
{
// Convert the binary input into Base64 UUEncoded output.
try
{
base64String = System.Convert.ToBase64String(binaryData, 0);
}
catch (System.ArgumentNullException)
{
System.Console.WriteLine("Binary data array is null.");
return "FAIL";
}
// done Encoding file
}
else
{
base64String = binaryData.ToString();
}
return base64String;
}
0 -
We did change our Certificate about four months ago. Click on the URL.
https://test2messaging.easylink.com/soap/sync
In IE click the Security lock and click the View Certificate on the bottom of popup. The click the Install Certificate. Try your Submit again.
0
Categories
- All Categories
- 111 Developer Announcements
- 49 Articles
- 102 General Questions
- 123 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 124 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 1 XM Fax