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 &#39;fault&#39; in the java binding operat=
ion has to be mapped to a &#39;message&#39; in the WSDL.</div><div><br></di=
v><div>The &#39;message&#39; can contain a part with name &#39;fault&#39; 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">&lt;<a href=3D"mailto:[email protected]"=
>[email protected]</a>&gt;</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&#39;s part my WSDL file:<br>
<br>
...<br>
 =A0&lt;message name=3D&quot;RawMSISDNMessage&quot;&gt;<br>
 =A0 =A0&lt;part name=3D&quot;rawMSISDN&quot; type=3D&quot;xsd:string&quot;=
/&gt;<br>
 =A0&lt;/message&gt;<br>
 =A0&lt;message name=3D&quot;FormattedMSISDNMessage&quot;&gt;<br>
 =A0 =A0&lt;part name=3D&quot;formattedMSISDN&quot; type=3D&quot;xsd:string=
&quot;/&gt;<br>
 =A0&lt;/message&gt;<br>
<br>
 =A0&lt;message name=3D&quot;InvalidParameterException&quot;&gt;<br>
 =A0 =A0&lt;part name=3D&quot;message&quot; type=3D&quot;xsd:string&quot;/&=
gt;<br>
 =A0&lt;/message&gt;<br>
<br>
 =A0&lt;portType name=3D&quot;CommonUtilityPT&quot;&gt;<br>
 =A0 =A0&lt;operation name=3D&quot;formatMSISDN&quot;&gt;<br>
 =A0 =A0 =A0&lt;input name=3D&quot;FormatMSISDNRequest&quot; message=3D&quo=
t;tns:RawMSISDNMessage&quot;/&gt;<br>
 =A0 =A0 =A0&lt;output name=3D&quot;FormatMSISDNResponse&quot;<br>
message=3D&quot;tns:FormattedMSISDNMessage&quot;/&gt;<br>
 =A0 =A0 =A0&lt;fault name=3D&quot;FormatMSISDNFault&quot;<br>
message=3D&quot;tns:InvalidParameterException&quot;/&gt;<br>
 =A0 =A0&lt;/operation&gt;<br>
 =A0&lt;/portType&gt;<br>
 =A0&lt;binding name=3D&quot;JavaBinding&quot; type=3D&quot;tns:CommonUtili=
tyPT&quot;&gt;<br>
 =A0 =A0&lt;java:binding/&gt;<br>
 =A0 =A0&lt;format:typeMapping encoding=3D&quot;Java&quot; style=3D&quot;Ja=
va&quot;&gt;<br>
 =A0 =A0 =A0&lt;format:typeMap typeName=3D&quot;xsd:string&quot; formatType=
=3D&quot;java.lang.String&quot;/&gt;<br>
 =A0 =A0&lt;/format:typeMapping&gt;<br>
 =A0 =A0&lt;operation name=3D&quot;formatMSISDN&quot;&gt;<br>
 =A0 =A0 =A0&lt;java:operation methodName=3D&quot;formatMSISDN&quot; method=
Type=3D&quot;static&quot;<br>
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0parameterOrder=3D&quot;rawMSISD=
N&quot;<br>
returnPart=3D&quot;formattedMSISDN&quot;/&gt;<br>
 =A0 =A0 =A0&lt;input name=3D&quot;FormatMSISDNRequest&quot;/&gt;<br>
 =A0 =A0 =A0&lt;output name=3D&quot;FormatMSISDNResponse&quot;/&gt;<br>
 =A0 =A0 =A0&lt;fault name=3D&quot;FormatMSISDNFault&quot;/&gt;<br>
 =A0 =A0&lt;/operation&gt;<br>
 =A0&lt;/binding&gt;<br>
 =A0&lt;service name=3D&quot;CommonUtility&quot;&gt;<br>
 =A0 =A0&lt;port name=3D&quot;JavaPort&quot; binding=3D&quot;tns:JavaBindin=
g&quot;&gt;<br>
 =A0 =A0 =A0&lt;java:address className=3D&quot;com.visitek.xlpoc.CommonUtil=
&quot;/&gt;<br>
 =A0 =A0&lt;/port&gt;<br>
 =A0&lt;/service&gt;<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(&quot;test&quot;);<br>
<br>
 =A0 =A0return &quot;test2&quot;;<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--