Hi Doug,
Once again, many thanks for you help. Here is the information you asked
for (By the way, this is all done using JWSDP 1.4):
***** WSDL Generation:
Contents of wsdl-gen-config.xml:
<configuration
xmlns="
http://java.sun.com/xml/ns/jax-rpc/ri/config">
<service
name="DataManager"
targetNamespace="
http://www.trilogi.co.uk/datamanager"
typeNamespace="
http://www.trilogi.co.uk/datamanager"
packageName="com.piper.trilogiview.datamanager">
<interface
name="com.piper.trilogiview.datamanager.DataManagerIF"/>
<typeMappingRegistry>
<additionalTypes>
<class
name="com.piper.trilogiview.datamanager.DatabaseType"/>
<class
name="com.piper.trilogiview.datamanager.GroupDataset"/>
</additionalTypes>
</typeMappingRegistry>
</service>
</configuration>
wscompile command is run from D:\eclipse\workspace\trilogiView as
follows:
C:\jwsdp-1.4\jaxrpc\bin\wscompile.bat -define -g
com/piper/trilogiview/datamanager/wsdl-gen-config.xml -model
WEB-INF/DataManager.gz -classpath WEB-INF/classes -nd WEB-INF
***** Generating server ties:
Contents of tie-gen-config.xml:
<configuration
xmlns="
http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl
location="D:\eclipse\workspace\trilogiView\WEB-INF\DataManager.wsdl"
packageName="com.piper.trilogiview.datamanager" />
</configuration>
wscompile command is run in a temporary area, D:\temp, so that they can
be built into a jar so that the generated class files don't conflict
with the one defining the web service. To be honest, having to do this
always feels like something we are doing incorrectly. This may also
highlight another problem occurring with the exceptions being created as
the generated DataManagerIF.class throws exceptions such as
InvalidPasswordException_Exception instead of the specified
InvalidPasswordException. So, if the server ties aren't made into a jar
file and the DataManagerImpl class is changed then many compilation
errors then occur. Perhaps it is something around this area that is
causing the problems I am getting? Anyway, here is how the command is
run for this:
C:\jwsdp-1.4\jaxrpc\bin\wscompile.bat -g -gen:server -f:searchschema
D:\eclipse\workspace\trilogiView\com\piper\trilogiview\datamanager\tie-g
en-config.xml
***** Generating client stubs:
Contents of client-stubs.xml:
<configuration xmlns="
http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl location="
http://localhost:1332/trilogiView/dataManagerRPC?WSDL"
packageName="com.piper.datamanagertest.jaxrpc"/>
</configuration>
wscompile command is run from D:\eclipse\workspace\dataManagerTest as
follows:
C:\jwsdp-1.4\jaxrpc\bin\wscompile.bat -gen:client -keep
com/piper/datamanagertest/jaxrpc/client-stubs.xml -f:searchschema
As you can see, we're not using the -d option on any of the commands. As
for capturing the message on the wire, I'm not entirely sure what you
mean. But if you still need this, if you could clarify slightly I will
get you that as well.
Many thanks,
Ian.
-----Original Message-----
From: Doug Kohlert [mailto:Doug.Kohlert_at_Sun.COM]
Sent: 11 May 2005 16:38
To: users_at_jax-rpc.dev.java.net
Subject: Re: exception handling
Ian,
Can you send the contents of tie-gen-config.xml, client-stubs.xml,
wsdl-gen-config.xml.
Also, are you using -d options on any of the commands?
What directory are your invoking the commands from?
If possible, can you capture the message on the wire and
send it to me?
Ian Jones wrote:
>Hi Doug,
>
>Thanks for that. However I have tried your suggestion and I still get
>the same result. Here are a few more details about what I'm doing -
any
>more help you can give will be greatly appreciated:
>
>This is where I throw the exception in my implementation class:
>
> public String login(String password) throws RemoteException,
>InvalidPasswordException {
> Environment env = Environment.getInstance();
> String dmPassword =
>env.getMainConfig().getDataManagerPassword();
> if (password.equals(dmPassword)) {
> String sessionId = getSessionId();
> return sessionId;
> } else {
> throw new InvalidPasswordException();
> }
> }
>
>And here is my latest version of the InvalidPasswordException class,
>with your suggested changes:
>
>public class InvalidPasswordException extends Exception {
>
> public InvalidPasswordException() {
> super("Invalid password");
> }
>
>}
>
>When the exception gets thrown by the implementation class the server
>generates the following stack trace (this is just the first few lines):
>
>
>
>SEVERE: JAXRPC.TIE.01: caught exception while handling request:
>com.piper.trilogiview.datamanager.exceptions.InvalidPasswordException:
>Invalid password
>com.piper.trilogiview.datamanager.exceptions.InvalidPasswordException:
>Invalid password
> at
>com.piper.trilogiview.datamanager.DataManagerImpl.login(DataManagerImpl
.
>java:53)
> at
>com.piper.trilogiview.datamanager.DataManagerIF_Tie.invoke_login(DataMa
n
>agerIF_Tie.java:248)
> at
>com.piper.trilogiview.datamanager.DataManagerIF_Tie.processingHook(Data
M
>anagerIF_Tie.java:1445)
> at
>com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:22
8
>)
> at
>com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletD
e
>legate.java:316)
>
>
>
>Meanwhile the stack trace of the exception caught on the client is this
>(again, just the first few lines):
>
>
>
>java.rmi.ServerException: JAXRPC.TIE.04: Internal Server Error
>(JAXRPC.TIE.01: caught exception while handling request:
>com.piper.trilogiview.datamanager.exceptions.InvalidPasswordException:
>Invalid password)
> at
>com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java
:
>372)
> at
>com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:224)
> at
>com.piper.datamanagertest.jaxrpc.DataManagerIF_Stub.login(DataManagerIF
_
>Stub.java:188)
> at
>com.piper.datamanagertest.testclient.LoginTest.testInvalidLogin(LoginTe
s
>t.java:71)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja
v
>a:39)
> at
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
r
>Impl.java:25)
>
>
>As you can see the client exception is a ServerException which seems to
>reference the InvalidPasswordException within it.
>
>I'm using wscompile to generate WSDL, server ties and client stubs from
>the Java interface. Is there anything I need to add to any of the
>config files for these to do with exceptions, as I haven't added
>anything at the moment? Or is there a flag I need to specify on
>wscompile? Here are the flags I'm using for wscompile at the moment:
>
>For WSDL generation:
>-define -g com/piper/datamanager/wsdl-gen-config.xml -model
>WEB-INF/DataManager.gz -classpath WEB-INF/classes -nd WEB-INF
>
>For generating server ties:
>-g -gen:server -f:searchschema com\piper\datamanager\tie-gen-config.xml
>
>For generating client stubs:
>-gen:client -keep com/piper/datamanagertest/jaxrpc/client-stubs.xml
>-f:searchschema
>
>Again, many thanks for any further help with this,
>
>Ian.
>
>-----Original Message-----
>From: Doug Kohlert [mailto:Doug.Kohlert_at_Sun.COM]
>Sent: 10 May 2005 18:28
>To: users_at_jax-rpc.dev.java.net
>Subject: Re: exception handling
>
>Ian,
>InvalidPasswordException_Exception is the proper name on the client.
Try
>
>modifying your
>exception class on the server to be:
>
>public class InvalidPasswordException extends Exception {
>
>public InvalidPasswordException() {
>
>super("bad password");
>
>}
>
>
>}
>
>and see if that works.
>
>Ian Jones wrote:
>
>
>
>>All,
>>
>>I'm attempting to throw a service-specific exception in my JAX-RPC web
>>
>>
>
>
>
>>service. This exception is defined, simply, as follows:
>>
>>public class InvalidPasswordException extends Exception {
>>
>>public InvalidPasswordException() {
>>
>>}
>>
>>}
>>
>>and is thrown in the interface of my web service here:
>>
>>String login(String password) throws RemoteException,
>>
>>InvalidPasswordException;
>>
>>I then use wscompile to generate the WSDL, server ties and client
>>stubs. However the client stub generated for the exception is called
>>InvalidPasswordException_Exception and this is thrown by the login
>>method's client stub. Is this what should happen?
>>
>>In my client I attempt to catch this
>>InvalidPasswordException_Exception exception as follows:
>>
>>try {
>>
>>client.login("random");
>>
>>fail("Password was not invalid");
>>
>>} catch (InvalidPasswordException_Exception e) {
>>
>>return;
>>
>>} catch (ServerException e) {
>>
>>fail(e.getMessage());
>>
>>} catch (Exception e) {
>>
>>e.printStackTrace();
>>
>>fail("failed due to exception " + e.getMessage());
>>
>>}
>>
>>In this case the server correctly attempts to throw a new
>>InvalidPasswordException, but the client catches a ServerException
>>which mentions the InvalidPasswordException within it's message. Is
>>this also correct? Shouldn't I just be able to catch an
>>InvalidPasswordException as specified by the service's interface?
>>
>>Many thanks for any help,
>>
>>Ian Jones
>>
>>Senior Analyst Developer
>>
>>Piper Group plc
>>
>>Email: ijones_at_piper-group.com
>>
>>Tel: + 44 (0) 1454 284900
>>
>>Fax: + 44 (0) 1454 284950
>>
>>www.piper-group.com <http://www.piper-group.com/>
>>
>>Information contained in this e-mail is intended for the use of the
>>addressee only, and is confidential and may be the subject of legal
>>professional privilege. Any dissemination, distribution, copying or
>>use of this communication without permission of the addressee is
>>strictly prohibited. The views expressed in this communication may not
>>
>>
>
>
>
>>necessarily be the views held by Piper Group plc.
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net