SoapException on JobSubmitService

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;

 

        }

Comments

  • You have to add the WSDL as a Web Reference.

  • Adding the below WSDL as a service reference in VisualStudio is not exposing JobSubmitService. That is the reason why I generated a proxy class which exposes JobSubmitService

    http://ws.easylink.com/JobSubmit/2011/01?WSDL

    ServiceReference

  • It has to be a Web Reference, not a Service.

  • After looking at your comment I added the WSDL as a web reference by saving the WSDL from the URL http://ws.easylink.com/JobSubmit/2011/01?WSDL as an XML file locally on my machine since I don't see a .asmx service available.

    Below is the error I'm running into now and it looks close to the error I received last time

    The remote server returned an error: (407) Proxy Authentication Required.

    Stack Trace:

    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)

       at System.Net.HttpWebRequest.GetRequestStream()

       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

       at EasyLinkFaxing.EasyLinkWebReference.JobSubmitService.JobSubmit(JobSubmitRequest JobSubmitRequest) in c:\Users\admin\Documents\Visual Studio 2013\Projects\EasyLinkFaxing\EasyLinkFaxing\Web References\EasyLinkWebReference\Reference.cs:line 104

  • The error is not coming from our server. Do you have a Proxy Server running?

    I import the WSDL as a Web Reference.

  • What version of Dev Studio are you using?

  • I'm using Visual Studio 2013. Also, I was able to successfully add a web reference directly now. Now I'm getting the original error I used to get earlier.

     

    An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

    Additional information: Error in parsing

     

       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

       at EasyLinkFaxing.LatestEasyLinkAPI.JobSubmitService.JobSubmit(JobSubmitRequest JobSubmitRequest) in c:\Users\admin\Documents\Visual Studio 2013\Projects\EasyLinkFaxing\EasyLinkFaxing\Web References\LatestEasyLinkAPI\Reference.cs:line 104

       at EasyLinkFaxing.Program.FaxJobSubmit() in c:\Users\admin\Documents\Visual Studio 2013\Projects\EasyLinkFaxing\EasyLinkFaxing\Program.cs:line 101

       at EasyLinkFaxing.Program.Main(String[] args) in c:\Users\admin\Documents\Visual Studio 2013\Projects\EasyLinkFaxing\EasyLinkFaxing\Program.cs:line 21

       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  • Error in Parsing means there is a problem in the code. Step through it in Debug to see were the error is happening.