Re: Handling Exception When Invoking Java Via WSIF
Gnanaprakash Ramswami <[email protected]> Wed, 26 May 2010 22:25:50 -0700
| Newsgroups | gmane.comp.apache.webservices.wsif.user |
|---|---|
| Message-ID | <[email protected]> |
--000feaf22677a3cc2e04878c9f00 Content-Type: text/plain; charset=ISO-8859-1 Hi Setya, The 'fault' in the java binding operation has to be mapped to a 'message' in the WSDL. The 'message' can contain a part with name 'fault' which is mapped to a user defined Exception type. Once you have this, WSIF will convert the Exception to a Fault and the exception object can be retrieved from the Fault parts. Hope it helps. Thanks Prakash On Tue, May 25, 2010 at 5:06 AM, Setya <[email protected]> wrote: > > Hi all, > > From BPEL, I need to catch exceptions thrown by invocation to Java method > via WSIF, but it always returns remoteFault instead. Is it possible at all > ? > > Here's part my WSDL file: > > ... > <message name="RawMSISDNMessage"> > <part name="rawMSISDN" type="xsd:string"/> > </message> > <message name="FormattedMSISDNMessage"> > <part name="formattedMSISDN" type="xsd:string"/> > </message> > > <message name="InvalidParameterException"> > <part name="message" type="xsd:string"/> > </message> > > <portType name="CommonUtilityPT"> > <operation name="formatMSISDN"> > <input name="FormatMSISDNRequest" message="tns:RawMSISDNMessage"/> > <output name="FormatMSISDNResponse" > message="tns:FormattedMSISDNMessage"/> > <fault name="FormatMSISDNFault" > message="tns:InvalidParameterException"/> > </operation> > </portType> > <binding name="JavaBinding" type="tns:CommonUtilityPT"> > <java:binding/> > <format:typeMapping encoding="Java" style="Java"> > <format:typeMap typeName="xsd:string" formatType="java.lang.String"/> > </format:typeMapping> > <operation name="formatMSISDN"> > <java:operation methodName="formatMSISDN" methodType="static" > parameterOrder="rawMSISDN" > returnPart="formattedMSISDN"/> > <input name="FormatMSISDNRequest"/> > <output name="FormatMSISDNResponse"/> > <fault name="FormatMSISDNFault"/> > </operation> > </binding> > <service name="CommonUtility"> > <port name="JavaPort" binding="tns:JavaBinding"> > <java:address className="com.visitek.xlpoc.CommonUtil"/> > </port> > </service> > ... > > And this is my Java class: > > public class InvalidParameterException extends Exception > { > public InvalidParameterException(String string) > { > super(string); > } > } > > public final class CommonUtil > { > public static String formatMSISDN(String rawMSISDN) throws > InvalidParameterException > { > throw new InvalidParameterException("test"); > > return "test2"; > } > } > > Any help would be greatly appreciated. > > > Regards, > > Setya > -- > View this message in context: > http://old.nabble.com/Handling-Exception-When-Invoking-Java-Via-WSIF-tp28667535p28667535.html > Sent from the WSIF - User mailing list archive at Nabble.com. > > --000feaf22677a3cc2e04878c9f00 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Setya,<div><br></div><div>The 'fault' in the java binding operat= ion has to be mapped to a 'message' in the WSDL.</div><div><br></di= v><div>The 'message' can contain a part with name 'fault' w= hich is mapped to a user defined Exception type.</div> <div><br></div><div>Once you have this, WSIF will convert the Exception to = a Fault and the exception object can be retrieved from the Fault parts.</di= v><div><br></div><div>Hope it helps.</div><div><br></div><div>Thanks</div> <div>Prakash</div><div><br><div class=3D"gmail_quote">On Tue, May 25, 2010 = at 5:06 AM, Setya <span dir=3D"ltr"><<a href=3D"mailto:[email protected]"= >[email protected]</a>></span> wrote:<br><blockquote class=3D"gmail_quote= " style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <br> Hi all,<br> <br> From BPEL, I need to catch exceptions thrown by invocation to Java method<b= r> via WSIF, but it always returns remoteFault instead. Is it possible at all = ?<br> <br> Here's part my WSDL file:<br> <br> ...<br> =A0<message name=3D"RawMSISDNMessage"><br> =A0 =A0<part name=3D"rawMSISDN" type=3D"xsd:string"= /><br> =A0</message><br> =A0<message name=3D"FormattedMSISDNMessage"><br> =A0 =A0<part name=3D"formattedMSISDN" type=3D"xsd:string= "/><br> =A0</message><br> <br> =A0<message name=3D"InvalidParameterException"><br> =A0 =A0<part name=3D"message" type=3D"xsd:string"/&= gt;<br> =A0</message><br> <br> =A0<portType name=3D"CommonUtilityPT"><br> =A0 =A0<operation name=3D"formatMSISDN"><br> =A0 =A0 =A0<input name=3D"FormatMSISDNRequest" message=3D&quo= t;tns:RawMSISDNMessage"/><br> =A0 =A0 =A0<output name=3D"FormatMSISDNResponse"<br> message=3D"tns:FormattedMSISDNMessage"/><br> =A0 =A0 =A0<fault name=3D"FormatMSISDNFault"<br> message=3D"tns:InvalidParameterException"/><br> =A0 =A0</operation><br> =A0</portType><br> =A0<binding name=3D"JavaBinding" type=3D"tns:CommonUtili= tyPT"><br> =A0 =A0<java:binding/><br> =A0 =A0<format:typeMapping encoding=3D"Java" style=3D"Ja= va"><br> =A0 =A0 =A0<format:typeMap typeName=3D"xsd:string" formatType= =3D"java.lang.String"/><br> =A0 =A0</format:typeMapping><br> =A0 =A0<operation name=3D"formatMSISDN"><br> =A0 =A0 =A0<java:operation methodName=3D"formatMSISDN" method= Type=3D"static"<br> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0parameterOrder=3D"rawMSISD= N"<br> returnPart=3D"formattedMSISDN"/><br> =A0 =A0 =A0<input name=3D"FormatMSISDNRequest"/><br> =A0 =A0 =A0<output name=3D"FormatMSISDNResponse"/><br> =A0 =A0 =A0<fault name=3D"FormatMSISDNFault"/><br> =A0 =A0</operation><br> =A0</binding><br> =A0<service name=3D"CommonUtility"><br> =A0 =A0<port name=3D"JavaPort" binding=3D"tns:JavaBindin= g"><br> =A0 =A0 =A0<java:address className=3D"com.visitek.xlpoc.CommonUtil= "/><br> =A0 =A0</port><br> =A0</service><br> ...<br> <br> And this is my Java class:<br> <br> public class InvalidParameterException extends Exception<br> {<br> =A0public InvalidParameterException(String string)<br> =A0{<br> =A0 =A0super(string);<br> =A0}<br> }<br> <br> public final class CommonUtil<br> {<br> =A0public static String formatMSISDN(String rawMSISDN) throws<br> InvalidParameterException<br> =A0{<br> =A0 =A0throw new InvalidParameterException("test");<br> <br> =A0 =A0return "test2";<br> =A0}<br> }<br> <br> Any help would be greatly appreciated.<br> <br> <br> Regards,<br> <br> Setya<br> <font color=3D"#888888">--<br> View this message in context: <a href=3D"http://old.nabble.com/Handling-Exc= eption-When-Invoking-Java-Via-WSIF-tp28667535p28667535.html" target=3D"_bla= nk">http://old.nabble.com/Handling-Exception-When-Invoking-Java-Via-WSIF-tp= 28667535p28667535.html</a><br> Sent from the WSIF - User mailing list archive at Nabble.com.<br> <br> </font></blockquote></div><br></div> --000feaf22677a3cc2e04878c9f00--