I was able to successfully submit a job through SOAPUI but when I try to do the same using Visual Studio I'm getting an Error "An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll". I compared with the sample C# code available on this forum and my code doesn't look very different. So I'm very confused on what went wrong here. Any recommendations would be greatly appreciated.
NOTE: I generated a Proxy Class using WSDL.exe and added it as a reference rather than adding a service reference.(Please check the ProxyClass Attached to see if something is wrong in it.)
Here is my JobSubmit method:
public static void FaxJobSubmit()
{
string MRN = string.Empty;
string XDN = "";
string ErrorMessage = "";
string FaxStatus = "";
RightFaxJobSubmitAPIProxyLibrary.JobSubmitService service = new RightFaxJobSubmitAPIProxyLibrary.JobSubmitService();
RightFaxJobSubmitAPIProxyLibrary.Request request = new RightFaxJobSubmitAPIProxyLibrary.Request();
//Autentication
RightFaxJobSubmitAPIProxyLibrary.RequestAuthentication reqAuth = new RightFaxJobSubmitAPIProxyLibrary.RequestAuthentication();
RightFaxJobSubmitAPIProxyLibrary.XDDSAuthType XDDSAuth = new RightFaxJobSubmitAPIProxyLibrary.XDDSAuthType();
RightFaxJobSubmitAPIProxyLibrary.UIDType UIDType = new RightFaxJobSubmitAPIProxyLibrary.UIDType();
UIDType.Value = "UserName";
XDDSAuth.RequesterID = UIDType;
XDDSAuth.Password = "password";
reqAuth.Item = XDDSAuth;
request.Authentication = reqAuth;
request.RequestID = "RequestID";
service.RequestValue = request;
//JobSubmitRequest
RightFaxJobSubmitAPIProxyLibrary.JobSubmitRequest FaxRequest = new RightFaxJobSubmitAPIProxyLibrary.JobSubmitRequest();
RightFaxJobSubmitAPIProxyLibrary.JobOptionsType jobOptions = new RightFaxJobSubmitAPIProxyLibrary.JobOptionsType();
RightFaxJobSubmitAPIProxyLibrary.FaxOptionsType faxOptions = new RightFaxJobSubmitAPIProxyLibrary.FaxOptionsType();
RightFaxJobSubmitAPIProxyLibrary.ContentsType contents = new RightFaxJobSubmitAPIProxyLibrary.ContentsType();
RightFaxJobSubmitAPIProxyLibrary.ContentPartType[] contentParts = new RightFaxJobSubmitAPIProxyLibrary.ContentPartType[1];
RightFaxJobSubmitAPIProxyLibrary.DocDataType DocData = new RightFaxJobSubmitAPIProxyLibrary.DocDataType();
RightFaxJobSubmitAPIProxyLibrary.EncodableStringType FileName = new EncodableStringType(); //New
RightFaxJobSubmitAPIProxyLibrary.MessageType msgType = new RightFaxJobSubmitAPIProxyLibrary.MessageType();
//JobSubmitResult
RightFaxJobSubmitAPIProxyLibrary.JobSubmitResult result = new RightFaxJobSubmitAPIProxyLibrary.JobSubmitResult();
RightFaxJobSubmitAPIProxyLibrary.MessageResultType MessageResult = new RightFaxJobSubmitAPIProxyLibrary.MessageResultType();
RightFaxJobSubmitAPIProxyLibrary.StatusTypeError ErrorList = new RightFaxJobSubmitAPIProxyLibrary.StatusTypeError();
//Set SubmitID
FaxRequest.SubmitId = Guid.NewGuid().ToString();
//Assign Message to Request
FaxRequest.Message = new RightFaxJobSubmitAPIProxyLibrary.MessageType[] { msgType };
//Set MessageID
msgType.MessageId = System.Environment.MachineName + DateTime.Now;
//Set FaxOptions
faxOptions.FaxMode = FaxModeType.fine;
faxOptions.PageOrientation = PageOrientationType.portrait;
jobOptions.FaxOptions = faxOptions;
msgType.JobOptions = jobOptions;
//Create lists for Destinations node
RightFaxJobSubmitAPIProxyLibrary.FaxType[] lists = new RightFaxJobSubmitAPIProxyLibrary.FaxType[1];
RightFaxJobSubmitAPIProxyLibrary.FaxType fType = new FaxType();
fType.Phone = "44078851000";//Pass Fax Number
fType.Salutation = "Fax Test";
lists[0] = fType;
msgType.Destinations = lists;
//Add Document
RightFaxJobSubmitAPIProxyLibrary.DocumentType[] DocumentSet = new RightFaxJobSubmitAPIProxyLibrary.DocumentType[1];
DocumentSet[0] = new RightFaxJobSubmitAPIProxyLibrary.DocumentType();
//string fileContent = File.ReadAllText(@C:\test\Abraham_Lincoln_O-55_1861-crop.jpg);
DocData.Value = File.ReadAllText(@C:\test\Abraham_Lincoln_O-55_1861-crop.jpg);
DocData.format = DocEncodingFormat.base64;
DocumentSet[0].Item = DocData;
DocumentSet[0].DocType = "JPEG";
DocumentSet[0].ItemElementName = ItemChoiceType.DocData;
FileName.Value = "Test";
DocumentSet[0].Filename = FileName;
FaxRequest.DocumentSet = DocumentSet;
//Call JobSubmit Method
result = service.JobSubmit(FaxRequest); // Currently failing with an error 'Error in Parsing'
MessageResult = result.MessageResult[0];
if (MessageResult.Status.ErrorList != null)
{
ErrorList = MessageResult.Status.ErrorList[0];
ErrorMessage = ErrorList.ErrorMessage;
}
FaxStatus = MessageResult.Status.StatusCode;
MRN = MessageResult.JobId.MRN;
XDN = MessageResult.JobId.XDN;
}