Hello Ken,
Thanks for the quick response.
Then the question turns to "Handling and Throwing Exceptions in XML Web
Services". Please correct me if I have misunderstood the problem.
From MSDN, we could see that exceptions thrown by an XML Web service method
created using ASP.NET are sent back to the client in the form of a SOAP
fault. A SOAP fault is a <Fault> XML element within a SOAP message that
specifies when an error occurred. When passing a SOAP fault, ASP.NET
follows the method prescribed for propagating errors back to a client by
the SOAP specification. The SOAP <Fault> XML element contains details such
as the exception string and the source of the exception. For details on
SOAP faults, see the W3C Web site (
http://www.w3c.org/TR/SOAP).
For details on how to coding it in .NET, please refer to MSDN topic:
"Handling and Throwing Exceptions in XML Web Services"
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhandlingraisingexc
eptionsinxmlwebservices.asp?frame=true
Does that answer your question?
Best regards,
Yanhong Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
!Content-Class: urn:content-classes:message
!From: "Ken Cox [Microsoft MVP]" <
[email protected]>
!Sender: "Ken Cox [Microsoft MVP]" <
[email protected]>
!References: <
[email protected]>
<
[email protected]>
!Subject: RE: Trapping a bad string in a Web service
!Date: Thu, 2 Oct 2003 05:34:10 -0700
!Lines: 93
!Message-ID: <
[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!Thread-Index: AcOI4Xrt4ijHKuTbS7+X8UcerKLcxw==
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:19685
!NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
!
!Hi Yanhong,
!
!Thanks for the reply.
!
!While I agree that the caller should be validating the
!values that it is passing (to be sure it is an integer and
!not a string), that doesn't fit the reality of Web
!services. Someone unknown and far away can be calling the
!Web service with data that causes an error/crash.
!
!I guess my goal is to find a way to return a friendly, non-
!revealing SOAP error message. How would I do that?
!
!Thanks,
!
!Ken
!
!
!
!>-----Original Message-----
!>Hello Ken,
!>
!>Thanks for posting in the group.
!>
!>If so, I think it is web service client's responsibility
!to trap for this
!>error. The parameter info is written into wsdl. The
!client could get it
!>when it adds web reference. There is no need for you to
!add error handling
!>for it. You could user SoapTrace tool to monitor the soap
!message under
!>this situation.
!>
!>Please post here if you have any more concerns.
!>
!>Best regards,
!>Yanhong Huang
!>Microsoft Online Partner Support
!>
!>Get Secure! -
www.microsoft.com/security
!>This posting is provided "AS IS" with no warranties, and
!confers no rights.
!>
!>--------------------
!>!Content-Class: urn:content-classes:message
!>!From: "Ken Cox [Microsoft MVP]"
!<
[email protected]>
!>!Sender: "Ken Cox [Microsoft MVP]"
!<
[email protected]>
!>!Subject: Trapping a bad string in a Web service
!>!Date: Wed, 1 Oct 2003 14:12:34 -0700
!>!Lines: 18
!>!Message-ID: <
[email protected]>
!>!MIME-Version: 1.0
!>!Content-Type: text/plain;
!>! charset="iso-8859-1"
!>!Content-Transfer-Encoding: 7bit
!>!X-Newsreader: Microsoft CDO for Windows 2000
!>!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!>!Thread-Index: AcOIYLu/2cEGQlGDSmmN9xozsn5DPA==
!>!Newsgroups:
!microsoft.public.dotnet.framework.aspnet.webservices
!>!Path: cpmsftngxa06.phx.gbl
!>!Xref: cpmsftngxa06.phx.gbl
!>microsoft.public.dotnet.framework.aspnet.webservices:19662
!>!NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!>!X-Tomcat-NG:
!microsoft.public.dotnet.framework.aspnet.webservices
!>!
!>!My Web service function is expecting an integer (123).
!>!However, I get a nasty error if the test page passes a
!>!string (aaaa) to it:
!>!
!>!<WebMethod()> Public Function READ_REC(ByVal intVal As
!>!Integer) As DataSet
!>!' Stuff here to check for the data but it is too late
!>!End Function
!>!
!>!How do I trap for this, since it is happening before I
!can
!>!get a Try...Catch into the equation?
!>!
!>!Should I just accept strings which I can then validate?
!>!
!>!Thanks,
!>!
!>!Ken
!>!
!>!
!>
!>.
!>
!