Hi All,

I have developed Simple webservice and Iam generarting the Client .In that
client iam calling the service then iam getting the error....

Error:--------------------------
Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could
not invoke service.. Nested exception is
org.codehaus.xfire.fault.XFireFault: java.lang.InstantiationException:
com.simple.Simple
org.codehaus.xfire.fault.XFireFault: java.lang.InstantiationException:
com.simple.Simple
        at
org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
        at
org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
        at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
        at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
        at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
        at 
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
        at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
        at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
        at org.codehaus.xfire.client.Client.invoke(Client.java:336)
        at 
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
        at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
        at $Proxy8.setName(Unknown Source)
        at com.simple.SimpleServiceClient.main(SimpleServiceClient.java:105)

This is My Client Code------------------------------

package com.simple;

import java.net.MalformedURLException;
import java.util.Collection;
import java.util.HashMap;
import javax.xml.namespace.QName;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.aegis.AegisBindingProvider;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;

public class SimpleServiceClient {

    private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
    private HashMap endpoints = new HashMap();
    private Service service0;

    public SimpleServiceClient() {
        create0();
        Endpoint SimpleLocalEndpointEP = service0 .addEndpoint(new
QName("http://simple.com";, "SimpleLocalEndpoint"), new
QName("http://simple.com";, "SimpleLocalBinding"),
"xfire.local://SimpleService");
        endpoints.put(new QName("http://simple.com";, "SimpleLocalEndpoint"),
SimpleLocalEndpointEP);
        Endpoint SimpleEP = service0 .addEndpoint(new
QName("http://simple.com";, "Simple"), new QName("http://simple.com";,
"SimpleSoapBinding"), "http://localhost:8083/Simple/services/Simple";);
        endpoints.put(new QName("http://simple.com";, "Simple"), SimpleEP);
    }

    public Object getEndpoint(Endpoint endpoint) {
        try {
            return proxyFactory.create((endpoint).getBinding(),
(endpoint).getUrl());
        } catch (MalformedURLException e) {
            throw new XFireRuntimeException("Invalid URL", e);
        }
    }

    public Object getEndpoint(QName name) {
        Endpoint endpoint = ((Endpoint) endpoints.get((name)));
        if ((endpoint) == null) {
            throw new IllegalStateException("No such endpoint!");
        }
        return getEndpoint((endpoint));
    }

    public Collection getEndpoints() {
        return endpoints.values();
    }

    private void create0() {
        System.out.println("Create0");
        TransportManager tm =
(org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager());
        HashMap props = new HashMap();
        props.put("annotations.allow.interface", true);
        System.out.println("HashMap Size"+props.size());
        AnnotationServiceFactory asf = new AnnotationServiceFactory(new
Jsr181WebAnnotations(), tm, new AegisBindingProvider(new
JaxbTypeRegistry()));
        asf.setBindingCreationEnabled(false);
        service0 = asf.create((com.simple.Simple.class), props);
        {
            System.out.println("In Side");
                AbstractSoapBinding soapBinding = 
asf.createSoap11Binding(service0,
new QName("http://simple.com";, "SimpleLocalBinding"),
"urn:xfire:transport:local");
        }
        {
                System.out.println("Out Side");
            AbstractSoapBinding soapBinding =
asf.createSoap11Binding(service0, new QName("http://simple.com";,
"SimpleSoapBinding"), "http://schemas.xmlsoap.org/soap/http";);
            System.out.println(soapBinding.getName());
        }
    }

    public Simple getSimpleLocalEndpoint() {
        return ((Simple)(this).getEndpoint(new QName("http://simple.com";,
"SimpleLocalEndpoint")));
    }

    public Simple getSimpleLocalEndpoint(String url) {
        Simple var = getSimpleLocalEndpoint();
        org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
        return var;
    }

    public Simple getSimple() {
        return ((Simple)(this).getEndpoint(new QName("http://simple.com";,
"Simple")));
    }

    public Simple getSimple(String url) {
        Simple var = getSimple();
        org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
        return var;
    }

    public static void main(String[] args) {
        

       
                SimpleServiceClient client = new SimpleServiceClient();
                        
                        //create a default service endpoint
                        Simple service = client.getSimple();
                         
                        //TODO: Add custom client code here
                                        //
                                        //service.yourServiceOperationHere();
                service.setName("Simple");
        
                System.out.println("test client completed");
                        System.exit(0);
   
                           }
}


Here is my Simple.java------

package com.simple;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService(name = "Simple", targetNamespace = "http://simple.com";)
@SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle =
SOAPBinding.ParameterStyle.WRAPPED)
public interface Simple {


    @WebMethod(operationName = "getName", action = "")
    @WebResult(name = "getNameReturn", targetNamespace =
"http://simple.com";)
    public String getName();

    @WebMethod(operationName = "setName", action = "setNameRequest")
    public void setName(
        @WebParam(name = "name", targetNamespace = "http://simple.com";)
        String name);

}


Please anybody have idea please advice me........................

David Harrigan wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> I have this code (for testing):
> 
> @Action(fault = [EMAIL PROTECTED](className = WebServiceException.class)})
>     public Object[] invoke(@WebParam(name = "parameters")
>     final Map<String, String> parameters) throws WebServiceException {
> 
>         throw new WebServiceException("200", "Blobby");
>     }
> 
> WebServiceException is defined as follows:
> 
> public class WebServiceException extends Exception {
>     private static final long serialVersionUID = 1L;
>     private final String faultCode;
> 
>     public WebServiceException(final String faultCode, final String
> message) {
>         super(message);
>         this.faultCode = faultCode;
>     }
> 
>     public String getFaultCode() {
>         return faultCode;
>     }
> }
> 
> In my client I have this:
> 
>  public static void main(final String[] args) {
>         final Service serviceModel = new
> AnnotationServiceFactory().create(RouterServiceImpl.class);
>         try {
>             final RouterService service = (RouterService)new
> XFireProxyFactory().create(serviceModel,
> "http://localhost:5080/foobar/services/RouterService";);
>             final Map<String, String> parameters = new HashMap<String,
> String>();
>             parameters.put("hello", "world");
>             final Object[] objects = service.invoke(parameters);
>             for(final Object o : objects) {
>                 System.out.println((String)o);
>             }
>         } catch(final MalformedURLException e) {
>             e.printStackTrace();
>         } catch(final WebServiceException e) {
>             System.out.println(e.getFaultCode());
>         }
>     }
> 
> 
> When I run the code I get this:dub
> 
> Exception in thread "main" org.codehaus.xfire.XFireRuntimeException:
> Could not invoke service.. Nested exception is
> org.codehaus.xfire.fault.XFireFault: Could not receive fault.. Nested
> exception is org.codehaus.xfire.fault.XFireFault: Couldn't instantiate
> class. uk.co.foobar.nexus.webservice.WebServiceException
> org.codehaus.xfire.fault.XFireFault: Could not receive fault.. Nested
> exception is org.codehaus.xfire.fault.XFireFault: Couldn't instantiate
> class. uk.co.foobar.nexus.webservice.WebServiceException
>       at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
>       at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83)
>       at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
>       at org.codehaus.xfire.client.Client.invoke(Client.java:336)
>       at 
> org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
>       at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
>       at $Proxy6.invoke(Unknown Source)
>       at com.stellestia.apps.WebService.main(WebService.java:22)
> Caused by: org.codehaus.xfire.XFireRuntimeException: Could not receive
> fault.. Nested exception is org.codehaus.xfire.fault.XFireFault:
> Couldn't instantiate class.
> uk.co.foobar.nexus.webservice.WebServiceException
>       at org.codehaus.xfire.client.Client.onReceive(Client.java:431)
>       at
> org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
>       at
> org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
>       at
> org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
>       at
> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
>       at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
>       ... 6 more
> Caused by: org.codehaus.xfire.fault.XFireFault: Couldn't instantiate
> class. uk.co.foobar.nexus.webservice.WebServiceException
>       at
> org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:196)
>       at
> org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
>       at
> org.codehaus.xfire.client.ClientFaultConverter.processFaultDetail(ClientFaultConverter.java:51)
>       at
> org.codehaus.xfire.client.ClientFaultConverter.invoke(ClientFaultConverter.java:32)
>       at
> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
>       at org.codehaus.xfire.client.Client.onReceive(Client.java:424)
>       ... 11 more
> Caused by: java.lang.InstantiationException:
> uk.co.foobar.nexus.webservice.WebServiceException
>       at java.lang.Class.newInstance0(Class.java:340)
>       at java.lang.Class.newInstance(Class.java:308)
>       at
> org.codehaus.xfire.aegis.type.basic.BeanType.createFromFault(BeanType.java:253)
>       at
> org.codehaus.xfire.aegis.type.basic.BeanType.readObject(BeanType.java:105)
>       ... 16 more
> 
> 
> I don't understand what I'm doing wrong. Can anyone shed light on how to
> get an expection passed all the way back to the client (as a SOAP Fault
> Code) so that I can deal with it (I know in the client that I can catch
> this exception, but the client could be in Ruby for example...)
> 
> Thanks everyone!
> 
> - -=david=-
> 
> - --
> 
> "life would be so much easier if we had the source code"
> PGP Key Id: 0xE2BE72FC
> Public Key: http://www.harrigan.info/public.asc
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFGdlRJa5vShOK+cvwRAmFFAKDigHHesLQmYXyGSKCrA1JFT+NgrACgh82P
> ovuXIZhOOQIVM76+dhNLCvU=
> =1SJO
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/XFireFault-Problem-Handling-Exception-tp11172651p14994512.html
Sent from the XFire - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to