You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Rh...@sybase.com on 2005/08/12 00:02:12 UTC

wsdl2java and wsdl:fault

Following is an excerpt from JAX-RPC 1.1, Section 4.3.6 WSDL Fault.  Based
upon this information, should I expect to see WSDL2Java generate the
InvalidTickerException class?  It currently does not, or at least I have
not been able to get it to do so.

----

The following shows an example of the mapping of a wsdl:fault to a service
specific
Java exception. The wsdl:message has a single part of type xsd:string:

<!-- WSDL Extract -->
<message name=”InvalidTickerException”>
      <part name=”tickerSymbol” type=”xsd:string”/>
</message>
<portType name=”StockQuoteProvider”>
      <operation name=”getLastTradePrice” ...>
            <input message=”tns:getLastTradePrice”/>
            <output message=”tns:getLastTradePriceResponse”/>
            <fault name=”InvalidTickerException”
message=”tns:InvalidTickerException”/>
      </operation>
</portType>

The following is the Java service endpoint interface derived from the above
WSDL port
type definition. Note that the getLastTradePrice method throws the
InvalidTickerException based on the mapping of the corresponding
wsdl:fault:

package com.example;
public interface StockQuoteProvider extends java.rmi.Remote {
      float getLastTradePrice(String tickerSymbol)
      throws java.rmi.RemoteException,
      com.example.InvalidTickerException;
}

In this example, the wsdl:fault element is mapped to a Java exception
com.example.
InvalidTickerException that extends the java.lang.Exception class. The name
of
Java exception is mapped from the name of the wsdl:message referenced by
the
message attribute of the wsdl:fault element. The following code snippet
shows the
mapped exception.

package com.example;
public class InvalidTickerException extends java.lang.Exception {
      public InvalidTickerException(String tickerSymbol) { ... }
      public getTickerSymbol() { ... }
}
__

Re: wsdl2java and wsdl:fault

Posted by Anne Thomas Manes <at...@gmail.com>.
Interesting...

The JAX-RPC spec is, in fact, not compliant with the WSDL 1.1 spec,
which says[1]:

"The fault message MUST have a single part. The use, encodingStyle and
namespace attributes are all used in the same way as with soap:body
(see section 3.5), only style="document" is assumed since faults do
not contain parameters."

What that means is that the fault <part> definition should reference
an element, not a type.

[1] http://www.w3.org/TR/wsdl#_soap:fault

Anne

On 8/11/05, Rhett.DeWall@sybase.com <Rh...@sybase.com> wrote:
> Following is an excerpt from JAX-RPC 1.1, Section 4.3.6 WSDL Fault.  Based
> upon this information, should I expect to see WSDL2Java generate the
> InvalidTickerException class?  It currently does not, or at least I have
> not been able to get it to do so.
> 
> ----
> 
> The following shows an example of the mapping of a wsdl:fault to a service
> specific
> Java exception. The wsdl:message has a single part of type xsd:string:
> 
> <!-- WSDL Extract -->
> <message name="InvalidTickerException">
>       <part name="tickerSymbol" type="xsd:string"/>
> </message>
> <portType name="StockQuoteProvider">
>       <operation name="getLastTradePrice" ...>
>             <input message="tns:getLastTradePrice"/>
>             <output message="tns:getLastTradePriceResponse"/>
>             <fault name="InvalidTickerException"
> message="tns:InvalidTickerException"/>
>       </operation>
> </portType>
> 
> The following is the Java service endpoint interface derived from the above
> WSDL port
> type definition. Note that the getLastTradePrice method throws the
> InvalidTickerException based on the mapping of the corresponding
> wsdl:fault:
> 
> package com.example;
> public interface StockQuoteProvider extends java.rmi.Remote {
>       float getLastTradePrice(String tickerSymbol)
>       throws java.rmi.RemoteException,
>       com.example.InvalidTickerException;
> }
> 
> In this example, the wsdl:fault element is mapped to a Java exception
> com.example.
> InvalidTickerException that extends the java.lang.Exception class. The name
> of
> Java exception is mapped from the name of the wsdl:message referenced by
> the
> message attribute of the wsdl:fault element. The following code snippet
> shows the
> mapped exception.
> 
> package com.example;
> public class InvalidTickerException extends java.lang.Exception {
>       public InvalidTickerException(String tickerSymbol) { ... }
>       public getTickerSymbol() { ... }
> }
> __