Hi S.Y.M.
Thanks for showing a great interest in my predicament. I really appreciate
your effort. And maybe I need to do some more work rather than look for a
silver bullet?
I had a try.. catch that caught a SqlException. Here is a snippet of my web
service in C#:
--
[System.Web.Services.WebMethod()]
public string insertSummaryReport(string xmlReport)
{
try
{
//Code to call a SQL Server stored procedure here
} catch (SqlException e)
{
return "Error " + e.ErrorCode + " " + e.Message.ToString();
}
}
---
When I run the web service in Visual Studio (ctrl + F5) I get the following
error displayed in the browser (Note that I have since corrected my original
reported error):
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="
http://po.ijs.gov.za/">515 : Cannot insert the value NULL
into column 'ProjectNo', table 'ijspo.dbo.SummaryReport'; column does not
allow nulls. INSERT fails.</string>
---
Based on your submission I changed the web service not to return a string
but to throw the exception.
However, InfoPath is still submitting the form successfully and I can longer
see the error when I run the web service with ctrl + F5 in Visual Studio!
Am I trying to have my cake and eat it at the same time? Do I need to build
SOAP extensions? My background is Java and you can see I'm VERY new to both
ASP.NET, C#, InfoPath and Web Services. For example I could have expected to
thro the exception as follows:
public string insertSummaryReport(string xmlReport) throw SqlException
but C# demands that I do that with the catch as follows
try
{
} catch (SqlException e)
{
throw e;
}
What am I doing wrong or missing? Like I said maybe I'm looking for a silver
bulet here which does not exist! Thanks for the help.
--
Regards,
Bowie M
:
I just realized that my previous post might not have been clear enough... For
InfoPath to show an error box, the last result returned from the web method
you are calling from your form must be an error. So if your web service
returns false or true, or 0 or 1 to indicate failure or success, InfoPath
will not display an error. The response that comes back from your web service
must be an error, so you must either not catch errors in your web method or
re-throw them in the catch block if you are catching them.
---
S.Y.M. Wong-A-Ton
:
Hi S.Y.M.
It is the web service that is throwing an error but InfoPath is "pick it
up". Instead InfoPath displays "The form was submitted successfully" when in
fact it wasn't.
How do I pass the error being thrown by the web service to an error box in
InfoPath?
--
Thanks & Regards,
Bowie M
:
Is your web service throwing errors? Or consuming them? InfoPath will display
an error box if the web service throws an error.
---
S.Y.M. Wong-A-Ton
:
Hi,
I am submitting an Infopath form to SQL server via a web service that calls
a stored procedure.
At some point I renamed the stored procedure without correcting the change
in the web service.
However, when I submitted the form using the web service, InfoPath returned
"successful" submit message! Of course no form was inserted to the SQL Server.
I then proceeded to test the web service outside of InfoPath and I got an
error message informing me that the stored procedure does not exist.
How can I pass on this message from the web service to InfoPath or failing
that how I can InfoPath pick up web service errors such as this?