You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pat <pa...@xvalheru.org> on 2006/03/08 17:27:20 UTC
defining different namespace for generated xmlbeans
Hi all,
I have a problem with generated XMLBeans for the AXIS2.
On server side I have something like this:
public class A {
public void method() throws MyException{...}
}
When I deploy it and generated Java sources from generated WSDL file, the
MyException is generated as an XMLBean and the sources look like this:
mypackage.MyException - is an interface
mypackage.impl.MyExceptionImpl - is the interface implementation
So, and I want to change the mypackage to something different (e.g.
mypackagex), because I want to use the original exception in the client side
(I know I have to update the stub). The final state will be:
mypackagex.MyException
mypackagex.impl.MyExceptionImpl
The communication I want should be:
1) at server side is thrown mypackage.MyException
2) througn AXIS2 the exception will be transported as mypackagex.MyException
(mypackagex.impl.MyException)
3) at client side I'll receive mypackagex.MyException (its implementation)
4) on the client side I can use mypackage.MyException
How can I do this ??? Or is there a better way how to do it ???
Thanks a lot.
Pat
Re: defining different namespace for generated xmlbeans
Posted by robert <ro...@gmail.com>.
>
> How can I do this ??? Or is there a better way how to do it ???
>
I'm not a fan of throwing exceptions with web services. There are those that
try - search the list and the subject comes up frequently.
What has always worked for me is to use 'extension base´ on all your return
types. Such as:
<complexType name="ReturnWebBase">
<sequence>
<element name="errorMessage" type="xsd:string"/>
<element name="successErrorCode" type="xsd:int"/>
</sequence>
</complexType>
<element name="wiseLogin">
<complexType>
<sequence>
<element name="user_name" type="xsd:string"/>
<element name="user_password" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="wiseLoginResponse">
<complexType>
<complexContent>
<extension base="tns:ReturnWebBase">
<sequence>
<element name="soap_session_id" type="xsd:string"/>
<element name="web_user_name" type="xsd:string"/>
</sequence>
</extension>
</complexContent>
</complexType>
</element>
So wiseLoginResponse extends ReturnWebBase. Any other services follows the
same pattern. In code it looks like:
try {
...
retElement.setWebUserName(userName);
retElement.setSoapSessionId(
authenticator.provisionSoapSessionId(userName));
retElement.setErrorMessage(MessagesCodes.getMessage(
MessagesCodes.SUCCESS));
retElement.setSuccessErrorCode(MessagesCodes.SUCCESS);
} catch (Exception ex) {
logger.error("SWAWiseEndpointSkeleton.wiseLogin:"
+ ex.getMessage(), ex);
retElement.setErrorMessage(ex.getMessage());
retElement.setSuccessErrorCode(MessagesCodes.FAILURE);
}
Of course there is always going to be those that prefer WSDL:Fault . Here's a
good explanation - although its based on jax-rpc which axis2 doesn't support
yet.
http://www.developer.com/java/web/article.php/3493491
HTH,
Robert
http://www.braziloutsource.com/
Em Quarta 08 Março 2006 13:27, o pat escreveu:
> Hi all,
>
> I have a problem with generated XMLBeans for the AXIS2.
>
> On server side I have something like this:
>
> public class A {
> public void method() throws MyException{...}
> }
>
> When I deploy it and generated Java sources from generated WSDL file, the
> MyException is generated as an XMLBean and the sources look like this:
> mypackage.MyException - is an interface
> mypackage.impl.MyExceptionImpl - is the interface implementation
>
> So, and I want to change the mypackage to something different (e.g.
> mypackagex), because I want to use the original exception in the client
> side (I know I have to update the stub). The final state will be:
> mypackagex.MyException
> mypackagex.impl.MyExceptionImpl
>
> The communication I want should be:
> 1) at server side is thrown mypackage.MyException
> 2) througn AXIS2 the exception will be transported as
> mypackagex.MyException (mypackagex.impl.MyException)
> 3) at client side I'll receive mypackagex.MyException (its implementation)
> 4) on the client side I can use mypackage.MyException
>
> How can I do this ??? Or is there a better way how to do it ???
>
> Thanks a lot.
>
> Pat
--