SoapException - Fault Element - Compatibility

S

Sambo

Hi All

I'll dot point a few things to try and give some clarity around the
problem I'm having, and the outcome I need:

The Web Service construction:

- My web service is developed in .NET 2.0
- My web service needs to be constructed/generated from an existing
WSDL
- The WSDL was written by a third party (a standards body)
- The WSDL is also used by other parties that I need to communicate
with (that do not use .NET and may not be running on a Windopws
platform)
- I will be comsuming the third party service and they will be
consuming mine

The problem:

Microsoft.NET "cleverly" handles exceptions as SoapException and maps
them back to a SOAP fault element. The custom WSDL I need to use to
generate my web service from contains a clearly defined fault element.
Unfortunately, WSDL.EXE does not recognise this and will not generate
an exception class from it for me to raise in code for that web method.

I need to know whether a client that is NOT written in MS.NET and NOT
running in a Windows environment will see the required fault element in
the WSDL produced by my web service after I have used WSDL.EXE to
generate it from the custom WSDL (that does contain the fault element
definition).

I have seen articles on consuming web services and using SOAP
extensions to read the fault element, likewise to produce a fault
element at runtime, but I need to be able to ensure the consuming
application (on a foreign platform) will see my web service's WSDL
correctly at design time (as defined by the standards body that issued
it for me to produce my service from).

Please help. I'm exhausted after reading the entire internet :)

Thanks in advance,

Sam
 
C

Cookie

Hi !

I need some help in invoking a .NET webservice from a Java client.

I do know how to build the .NET Web service, the issue is what exactly
do I need to do to invoke from a Java client

Thanks in advance
 
C

Cookie

Hi !

I need some help in invoking a .NET webservice from a Java client.

I do know how to build the .NET Web service, the issue is what exactly
do I need to do to invoke from a Java client

Thanks in advance
 
J

John Saunders

Sambo said:
Hi All

I'll dot point a few things to try and give some clarity around the
problem I'm having, and the outcome I need:

The Web Service construction:

- My web service is developed in .NET 2.0
- My web service needs to be constructed/generated from an existing
WSDL
- The WSDL was written by a third party (a standards body)
- The WSDL is also used by other parties that I need to communicate
with (that do not use .NET and may not be running on a Windopws
platform)
- I will be comsuming the third party service and they will be
consuming mine

The problem:

Microsoft.NET "cleverly" handles exceptions as SoapException and maps
them back to a SOAP fault element. The custom WSDL I need to use to
generate my web service from contains a clearly defined fault element.
Unfortunately, WSDL.EXE does not recognise this and will not generate
an exception class from it for me to raise in code for that web method.

You can do this. In order to send a SOAP Fault back to your client, you need
to explicitly throw a SoapException. Use the constructor overload that
allows you to set the faultcode and actor elements of the fault.

You may or may not be able to do this with your WSDL, but since I defined my
own, here's what I was able to do: I defined all of my faults in a separate
schema. I ran this schema through xsd.exe to generate the appropriate .NET
types for the faults. When I want to return a particular SOAP Fault, I
simply create an instance of one of the fault types and fill in the
appropriate fields. I then serialize this object to XML, and pass that XML
as the details parameter of the SoapException constructor.

I have tested this with a Java client. As you mention in your post, Java
sensibly translates fault elements into exceptions. My test java client
correctly caught the faults I returned, and was able to process the contents
as properties of the Java exception object.

Good Luck,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top