RE: Can't compile web service with exception
Hello Philippe, I was following another thread on this topic too. It seems that the discussion on that thread, as well as what you said, indicate that one has to __manually__ edit the wsdl file generated by Java2WSDL. Could you confirm the following: 1. Run Java2WSDL to generate WSDL file. 2. Edit the WDSL file to add the fault information like the following: In portType statement: wsdl:operation name=testException wsdl:input message=tns:testExceptionRequest/ wsdl:output message=tns:testExceptionResult/ wsdl:fault name=myFault message=tns:Exception/ /wsdl:operation In portBinding statement: wsdl:binding fault name=soapapiFault soap:fault name='myFault' use='literal' / /fault /wsdl:binding 3. Run WSDL2Java to generate the stubs. 4. Compile my implementation class along with the generated files. So I would have to do this hand edit of the WSDL each time I modified my interface? I think someone in the other thread mentioned that this was caused by a bug in AXIS? Is this true? Is there no work-around for this (other than the hand editing)? Many thanks. V --- philippe ventrillon [EMAIL PROTECTED] wrote: Hi I think if you are going from wsdl file you are supposed to Declare a message for the fault put somehting like that in your porttype operation name='getCurrentLanguageCursorPage' input message='tns:getCurrentLanguageCursorPageIn'/ output message='tns:getCurrentLanguageCursorPageOut'/ fault name='soapapiFault' message='tns:soapapiFault'/ /operation Put something like that in the portBinding fault name=soapapiFault soap:fault name='soapapiFault' use='literal' / /fault I imagine that when you invoke wsdl2Java it regenerates the service (with no throws clause) but not the impl class --- Philippe __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
RE: Can't compile web service with exception
Philippe, One other question... What's the difference between using soap:fault and wsdl:fault ? Also, I forgot to say... yes you are correct. My implementation class is not touched by the WSDL2Java command. Each time I change my interface (my portType), for example to add a new method or change a method prototype, I have to make the corresponding change in my implementation class by hand. v --- philippe ventrillon [EMAIL PROTECTED] wrote: Hi I think if you are going from wsdl file you are supposed to Declare a message for the fault put somehting like that in your porttype operation name='getCurrentLanguageCursorPage' input message='tns:getCurrentLanguageCursorPageIn'/ output message='tns:getCurrentLanguageCursorPageOut'/ fault name='soapapiFault' message='tns:soapapiFault'/ /operation Put something like that in the portBinding fault name=soapapiFault soap:fault name='soapapiFault' use='literal' / /fault I imagine that when you invoke wsdl2Java it regenerates the service (with no throws clause) but not the impl class --- Philippe -Original Message- From: Rhimbo [mailto:[EMAIL PROTECTED] Sent: jeudi 6 avril 2006 02:49 To: Axis users Subject: Can't compile web service with exception Hi all, I too am having trouble with exceptions. I can't even get past compilation now. I added a simple method to my interface definition: Family.java: public void testException() throws Exception; Here's the implementation: FamilyImpl.java: public void testException() throws Exception { throw new Exception(Well take that!); } I did: $ java org.apache.axis.wsdl.Java2WSDL -o family.wsdl \ --implClass disney.dis.family.FamilyImpl \ -lhttp://localhost:8080/axis/services/familyAccounts; \ -pdisney.dis.family urn:familyAccounts \ disney.dis.family.Family to generate the family.wsdl file. Then I did: $ java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s \ -p disney.dis.family family.wsdl When I compile, I get these errors: FamilyAccountsSoapBindingImpl.java:123: testException() in disney.dis.family.FamilyAccountsSoapBindingImpl cannot implement testException() in disney.dis.family.Family; overridden method does not throw java.lang.Exception public void testException() throws java.lang.Exception ^ FamilyImpl.java:1105: testException() in disney.dis.family.FamilyImpl cannot implement testException() in disney.dis.family.Family; overridden method does not throw java.lang.Exception public void testException() throws Exception Apparently the compiler thinks that my method prototype in the Family.java interface definition doesn't throw Exception. But it does (above). More strangely, here is the prototype from the _generated_ Family.java file: public void testException() throws java.rmi.RemoteException; WSDL2Java added throws java.rmi.RemoteException but not throws Exception. Why is WSDL2Java not adding the throws Exception to the method prototype in the generated Family.java interface file? I followed a few threads the past several days about tweaking the wsdl file to get exception handling correct. I admit I didn't quite follow. Is there something I need to do after generating the wsdl file, before running the WSDL2Java command, to get exceptions to work? Here is excerpt from the generated WSDL below: wsdl:message name=testExceptionResponse /wsdl:message wsdl:message name=testExceptionRequest /wsdl:message wsdl:operation name=testException wsdl:input message=impl:testExceptionRequest name=testExceptionRequest/ wsdl:output message=impl:testExceptionResponse name=testExceptionResponse/ /wsdl:operation wsdl:operation name=testException wsdlsoap:operation soapAction=/ wsdl:input name=testExceptionRequest wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:familyAccounts use=encoded/ /wsdl:input wsdl:output name=testExceptionResponse wsdlsoap:body encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; namespace=urn:familyAccounts use=encoded/ /wsdl:output /wsdl:operation Thanks, Vartan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
RE: Can't compile web service with exception
Folks, I'm trying to create the wsdl:fault element in my wsdl file. Can anyone tell me what value I should use for the message parameter? What namespace should I use? I tried using the impl: prefix that I see throught my wsdl file. But I still get the exception shown below: I want to indicate that my method throws java.lang.Exception. How do I specify this? It appears that the string I put in the message parameter ends up appended to the throws clause on my method in the interface file that AXIS auto-generates. But I can't get a clean WSDL2Java run when I put the exception class name. Here is the wsdl:fault ... element I added to my wsdl: wsdl:operation name=testException wsdl:input message=impl:testExceptionRequest name=testExceptionRequest/ wsdl:output message=impl:testExceptionResponse name=testExceptionResponse/ wsdl:fault name=myException message=impl:Exception / /wsdl:operation But I get the following AXIS exceptions when I run $ java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p foo foo.wsdl java.io.IOException: input .., output .. or fault .. in portType with undefined message found. message name is '{urn:foo}Exception' at org.apache.axis.wsdl.symbolTable.SymbolTable.ensureOperationMessageValid(SymbolTable.java:1504) ... ... Thanks all. V --- Rhimbo [EMAIL PROTECTED] wrote: Philippe, One other question... What's the difference between using soap:fault and wsdl:fault ? Also, I forgot to say... yes you are correct. My implementation class is not touched by the WSDL2Java command. Each time I change my interface (my portType), for example to add a new method or change a method prototype, I have to make the corresponding change in my implementation class by hand. v --- philippe ventrillon [EMAIL PROTECTED] wrote: Hi I think if you are going from wsdl file you are supposed to Declare a message for the fault put somehting like that in your porttype operation name='getCurrentLanguageCursorPage' input message='tns:getCurrentLanguageCursorPageIn'/ output message='tns:getCurrentLanguageCursorPageOut'/ fault name='soapapiFault' message='tns:soapapiFault'/ /operation Put something like that in the portBinding fault name=soapapiFault soap:fault name='soapapiFault' use='literal' / /fault I imagine that when you invoke wsdl2Java it regenerates the service (with no throws clause) but not the impl class --- Philippe -Original Message- From: Rhimbo [mailto:[EMAIL PROTECTED] Sent: jeudi 6 avril 2006 02:49 To: Axis users Subject: Can't compile web service with exception Hi all, I too am having trouble with exceptions. I can't even get past compilation now. I added a simple method to my interface definition: Family.java: public void testException() throws Exception; Here's the implementation: FamilyImpl.java: public void testException() throws Exception { throw new Exception(Well take that!); } I did: $ java org.apache.axis.wsdl.Java2WSDL -o family.wsdl \ --implClass disney.dis.family.FamilyImpl \ -lhttp://localhost:8080/axis/services/familyAccounts; \ -pdisney.dis.family urn:familyAccounts \ disney.dis.family.Family to generate the family.wsdl file. Then I did: $ java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s \ -p disney.dis.family family.wsdl When I compile, I get these errors: FamilyAccountsSoapBindingImpl.java:123: testException() in disney.dis.family.FamilyAccountsSoapBindingImpl cannot implement testException() in disney.dis.family.Family; overridden method does not throw java.lang.Exception public void testException() throws java.lang.Exception ^ FamilyImpl.java:1105: testException() in disney.dis.family.FamilyImpl cannot implement testException() in disney.dis.family.Family; overridden method does not throw java.lang.Exception public void testException() throws Exception Apparently the compiler thinks that my method prototype in the Family.java interface definition doesn't throw Exception. But it does (above). More strangely, here is the prototype from the _generated_ Family.java file: public void testException() throws java.rmi.RemoteException; WSDL2Java added throws java.rmi.RemoteException but not throws Exception. Why is WSDL2Java not adding the throws Exception to the method prototype in the generated Family.java interface file? I followed a few threads the past several days about tweaking the wsdl file to get exception handling correct. I admit I didn't quite follow. Is there something I need to do after generating the wsdl file,