Can some one please help me. I set up the API with correct username and password but I'm getting the following error
XOA-2909 [User authentication not accepted] : login not permitted: reason code = 1000 msg-not found
I commented out some code and used the default values. Here is the code:
public void SendJob()
{
//JobSubmitRequest Fax
// setup EMsgAPI object - EM
JobSubmit.JobSubmitService EM = new JobSubmit.JobSubmitService();
// setup Authentication objects
JobSubmit.RequestAuthentication reqAuth = new JobSubmit.RequestAuthentication();
JobSubmit.XDDSAuthType XDDSAuth = new JobSubmit.XDDSAuthType();
JobSubmit.UIDType uid = new JobSubmit.UIDType();
// init Authentication objects
XDDSAuth.Password = "password";
uid.Value = "username";
XDDSAuth.RequesterID = uid;
reqAuth.Item = XDDSAuth;
// Setup MessageObject
JobSubmit.MessageType[] JS_Message = new JobSubmit.MessageType[1];
JS_Message[0] = new JobSubmit.MessageType();
// Setup JobOptions - CREF, Billing Code, FAX
JobSubmit.JobOptionsType JS_JobOptions = new JobSubmit.JobOptionsType();
JobSubmit.EncodableStringType JS_CRef = new JobSubmit.EncodableStringType();
JobSubmit.EncodableStringType JS_BCode = new JobSubmit.EncodableStringType();
JobSubmit.FaxOptionsType JS_FaxOptions = new JobSubmit.FaxOptionsType();
DateTime StartDateValue = new DateTime();
StartDateValue = DateTime.Now.AddHours(1);
DateTime EndDateValue = new DateTime();
EndDateValue = DateTime.Now.AddHours(2);
JobSubmit.DeliveryType ScheduledDelivery = new JobSubmit.DeliveryType();
ScheduledDelivery.Schedule = JobSubmit.ScheduleType.scheduled;
ScheduledDelivery.ScheduleSpecified = true;
ScheduledDelivery.StartTimeSpecified = true;
ScheduledDelivery.StopTimeSpecified = true;
ScheduledDelivery.StartTime = StartDateValue;
ScheduledDelivery.StopTime = EndDateValue;
JS_BCode.Value = "123456789_submittfaxjob";//txtBC.Text;
JS_JobOptions.BillingCode = JS_BCode;
JS_CRef.Value = "217340987_submitfaxjob"; //txtCRef.Text;
JS_JobOptions.CustomerReference = JS_CRef;
// Set FaxOptions
//JS_FaxOptions.FaxMode = EMsgAPI_Demo.EMsgAPI_JobSubmit201101.FaxModeType.fine;
//JS_FaxOptions.FaxModeSpecified = true;
// Set Retry Algo
JS_FaxOptions.DeliveryRetryPattern = "11";
JobSubmit.FaxCoversheetOptionType CoverSheet = new JobSubmit.FaxCoversheetOptionType();
CoverSheet.UseCoversheet = JobSubmit.YesNo.yes;
JS_FaxOptions.FaxCoversheet = CoverSheet;
// Set PilotLine
JobSubmit.FaxPilotlineOptionType PilotLine = new JobSubmit.FaxPilotlineOptionType();
string pilot = "1";
switch (pilot)//(txtPilotLine.Text)
{
case "1":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type1;
break;
case "2":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type2;
break;
case "3":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type3;
break;
case "4":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type4;
break;
case "5":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type5;
break;
case "6":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type6;
break;
case "7":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type7;
break;
case "8":
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.type8;
break;
default:
PilotLine.PilotlineStyle = JobSubmit.PilotlineStyleType.none;
break;
}
PilotLine.PilotlineStyleSpecified = true;
PilotLine.PilotlineText = "PILOTLINETEXT";
// 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;
JS_CRef = null;
JS_BCode = null;
// Setup Documents
JobSubmit.DocumentType[] JS_Documents = new JobSubmit.DocumentType[2];
JS_Documents[0] = new JobSubmit.DocumentType();
// Setup reusable variables for the document
JobSubmit.DocDataType DocData = new JobSubmit.DocDataType();
string File;
//// Setup Document 1 - PDF
File = ReadAndEncodedFile(@D:\sample.pdf, true);
DocData.format = JobSubmit.DocEncodingFormat.base64;
DocData.Value = File;
JobSubmit.EncodableStringType fname = new Fax2Mail.JobSubmit.EncodableStringType();
fname.Value = "sample.pdf";
JS_Documents[0].Item = DocData;
JS_Documents[0].Filename = fname;
JS_Documents[0].DocType = "PDF";
JS_Documents[0].ItemElementName = JobSubmit.ItemChoiceType.DocData;
JS_Documents[0].@ref = "Doc1";
DocData = null;
// Setup Content
JobSubmit.ContentsType EM_Content = new JobSubmit.ContentsType();
EM_Content = new JobSubmit.ContentsType();
JobSubmit.ContentPartType[] JS_Content = new JobSubmit.ContentPartType[1];
JS_Content[0] = new JobSubmit.ContentPartType();
//JS_Content[1] = new EMsgAPI_Demo.EMsgAPI_JobSubmit201101.ContentPartType();
// Setup references to documents
JS_Content[0].Item = "Doc1";
JS_Content[0].Treatment = JobSubmit.TreatmentType.body;
JS_Content[0].TreatmentSpecified = true;
// Setup Destination
JobSubmit.FaxType[] delivery = new JobSubmit.FaxType[1];
delivery[0] = new JobSubmit.FaxType();
delivery[0].Phone = "Number";
delivery[0].@ref = "Fax Number Entered";
JS_Message[0].Destinations = delivery;
//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
JobSubmit.Request Request = new JobSubmit.Request();
JobSubmit.Response Response = new JobSubmit.Response();
JobSubmit.JobSubmitRequest JS_Request = new JobSubmit.JobSubmitRequest();
JobSubmit.JobSubmitResult JS_Result = new JobSubmit.JobSubmitResult();
// Setup Proxy server and EMsgAPIConnect URL for posting data
Set_Server_and_Proxy(EM);
//// Setup Reqeust Object
//if (true)//(cmbServer.Text.Contains("Async"))
//{
// Request.SenderKey = "http://www.bdrsoftware.com/Service1.asmx";
//}
// 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;
//string jbNumber = 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
if (true)//(chkResult)
{
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 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;
}
private void Set_Server_and_Proxy(System.Web.Services.Protocols.SoapHttpClientProtocol EM)
{
EM.Url = "https://messaging.easylink.com/soap/sync"; //GetSystemServer(); //the EasyLink URL to submit to.
//if (chkProxyTrace.Checked)
//EM.Proxy = new System.Net.WebProxy("http://localhost:8080");
//if (chkUseProxy.Checked)
//{
//EM.Proxy = new System.Net.WebProxy(txtProxyIP.Text);
//EM.Credentials = new System.Net.NetworkCredential(txtProxyUser.Text, txtProxyPass.Text);
//}
}
//used to extract XML
static void serializeResult(String filename, System.Object res)
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(res.GetType());
System.IO.TextWriter w = new System.IO.StreamWriter(filename);
x.Serialize(w, res);
w.Close();
}
Here is the result.xml
<?xml version="1.0" encoding="utf-8"?>
<StatusCode>2209</StatusCode>
<StatusMessage>User authentication not accepted</StatusMessage>
<ErrorList>
<Error>
<ErrorCode>2909</ErrorCode>
<ErrorMessage>XOA-2909 [User authentication not accepted] : login not permitted: reason code = 1000 msg-not found</ErrorMessage>
</Error>
</ErrorList>
<SubmissionTime>2013-05-30T00:44:12.552Z</SubmissionTime>
<CompletionTime>2013-05-30T00:44:12.625Z</CompletionTime>
</Status>
</JobSubmitResult>
Here is the emrepsonse.xml
<?xml version="1.0" encoding="utf-8"?>
<RequestID>RequestID</RequestID>
<ProcessingID>0ACD0729-1364-130530004412552</ProcessingID>
</Response>
I would truly appreciate quick repsonse.
Thanks