Hi Robert,
You need to use the annotationservicefactory on your server side:
<service>
<serviceFactory>org.codehaus.xfire.annoatation.AnnotationServiceFactory</serviceFactory>
...
</service>
Also, if you generated that client via WSGen, which generates JAXB
beans, then insetad you'll want to make sure you're using the
JaxbServiceFactory in your services.xml and on the client side as well:
<service>
<serviceFactory>org.codehaus.xfire.jaxb2.JaxbServiceFactory</serviceFactory>
...
</service>
Regards,
- Dan
Robert Breedt wrote:
Hi Tomek
Here are the settings for the server service.
Service.xml
<service>
<name>PdfService</name>
<serviceClass>
com.dnaprojects.designserver.api.webservice.outgoing.IPdfService
</serviceClass>
<implementationClass>
com.dnaprojects.api.webservice.impl.PdfService
</implementationClass>
<properties>
<property key="mtom-enabled">true</property>
</properties>
</service>
My client implementation is as follows:
ServiceLocator:
public class PDFServiceLocator {
private static final Log log =
LogFactory.getLog(PDFServiceLocator.class);
private static String serviceEndpoint =
"http://localhost/design-server-8.0.1/webservice/PdfService";
private static PdfServicePortType pdfService;
private static final Object lock = new Object();
public static PdfServicePortType getPdfService() {
if (pdfService == null) {
synchronized (lock) {
if (pdfService == null) {
try {
Service serviceModel =
new AnnotationServiceFactory()
.create(PdfServiceImpl.class);
//serviceModel.addFaultHandler(new PDFFaultHandler());
serviceModel.setProperty("mtom-enabled", "true");
serviceModel.setProperty(
HttpTransport.CHUNKING_ENABLED, "true");
pdfService =
(PdfServicePortType) new XFireProxyFactory()
.create(serviceModel, serviceEndpoint);
Client client =
Client.getInstance(pdfService);
//client.addFaultHandler(new DefaultFaultHandler());
client.addFaultHandler(new PDFFaultHandler());
} catch (Throwable t) {
log.fatal("unable to
connect to remote web service", t);
}
}
}
if (pdfService == null) {
throw new RuntimeException(
"PDF Service has not
been properly initialized");
}
}
return pdfService;
}
}
Interface:
@WebService(name = "PdfServicePortType", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle =
SOAPBinding.ParameterStyle.WRAPPED)
public interface PdfServicePortType {
@WebMethod(operationName = "createPrintReadyPDF", action = "")
@WebResult(name = "out", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
public byte[] createPrintReadyPDF(
@WebParam(name = "in0", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
String in0,
@WebParam(name = "in1", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
String in1,
@WebParam(name = "in2", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
String in2,
@WebParam(name = "in3", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
String in3,
@WebParam(name = "in4", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
String in4,
@WebParam(name = "in5", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
WSDesignSize in5,
@WebParam(name = "in6", targetNamespace =
"http://outgoing.webservice.api.designserver.dnaprojects.com")
byte[] in6)
throws AssetNotFoundException, CallerAuthenticationException,
CallerAuthorizationException, InsufficientKeysException,
KeyServerUnavailableException, KeySystemAuthenticationException,
OneTimeUseImageException, PdfGenerationException
;
}
Exception trying to catch:
package com.dnaprojects.designserver.api.webservice.outgoing;
import javax.xml.namespace.QName;
import org.codehaus.xfire.fault.FaultInfoException;
public class InsufficientKeysException
extends FaultInfoException
{
private
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException faultInfo;
public InsufficientKeysException(String message,
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
public InsufficientKeysException(String message, Throwable t,
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException faultInfo) {
super(message, t);
this.faultInfo = faultInfo;
}
public
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException getFaultInfo() {
return faultInfo;
}
public static QName getFaultName() {
return new
QName("http://outgoing.webservice.api.designserver.dnaprojects.com",
"InsufficientKeysException");
}
}
-----Original Message-----
From: Tomek Sztelak [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 09, 2006 3:40 PM
To: [email protected]
Subject: Re: [xfire-user] Custom Exceptions not being sent correctly
Can you post your client and server config ?
On 11/9/06, Robert Breedt <[EMAIL PROTECTED]> wrote:
Hey guys
I have set up my webservice to throw a custom exception. My problem is
that when I call the service, it comes back with a XFireRuntime
exception. I attempted to create my own faulthandler which I extended
from the defaultFaultHanlder but when I checked the
context.getProperty(EXCEPTION) it is null. If I examine the body, I
can see that in the
context.getExchange().getBody() that the nested exception is my
exception:
"org.codehaus.xfire.fault.XFireFault: Fault:
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException"
org.codehaus.xfire.XFireRuntimeException: Could not invoke service..
Nested exception is
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException:
Fault:
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffi
cientKeysException
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffici
entKeysException:
Fault:
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffi
cientKeysException
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo
rAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo
nstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
org.codehaus.xfire.aegis.type.basic.BeanType.createFromFault(BeanType.
java:260)
at
org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:
120)
at
org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindi
ngProvider.java:154)
at
org.codehaus.xfire.client.ClientFaultConverter.processFaultDetail(Clie
ntFaultConverter.java:51)
at
org.codehaus.xfire.client.ClientFaultConverter.invoke(ClientFaultConve
rter.java:32)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java
:131)
at
org.codehaus.xfire.client.Client.onReceive(Client.java:400)
at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChanne
l.java:139)
at
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48
)
at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.ja
va:26)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java
:131)
at
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
at
org.codehaus.xfire.client.Client.invoke(Client.java:335)
at
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at
org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy84.createPrintReadyPDF(Unknown Source)
at
com.createads.webservice.impl.AjaxService.testPDF(AjaxService.java:788
)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
n(AopUtils.java:335)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamic
AopProxy.java:165)
at $Proxy78.testPDF(Unknown Source)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:239)
at
uk.ltd.getahead.dwr.impl.DefaultExecProcessor.handle(DefaultExecProces
sor.java:48)
at
uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java
:81)
at
uk.ltd.getahead.dwr.AbstractDWRServlet.doPost(AbstractDWRServlet.java:
162)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
cationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
lterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa
lve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa
lve.java:178)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticat
orBase.java:432)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
va:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
va:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
e.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.pr
ocessConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoi
nt.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFoll
owerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPo
ol.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.codehaus.xfire.fault.XFireFault: Fault:
com.dnaprojects.designserver.api.webservice.outgoing.exception.Insuffi
cientKeysException
at
org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11Fault
Serializer.java:31)
at
org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSeri
alizer.java:28)
at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadH
eadersHandler.java:111)
at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersH
andler.java:67)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java
:131)
at
org.codehaus.xfire.client.Client.onReceive(Client.java:382)
What am I doing wrong?
Thanks
Rob
--
-----
When one of our products stops working, we'll blame another vendor
within 24 hours.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
--
Dan Diephouse
(616) 971-2053
Envoi Solutions LLC
http://netzooid.com
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email