facebook

[Closed] Problem with web service client generator

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #262689 Reply

    klingmank
    Member

    I have the 5.1 install.

    I created a web service application JamesRegexWS

    I created a little test web service (EchoService) that just has the example method in it. I can see the WSDL either in a browser or via the web service explorer. All looks good so far.

    I created a client by using the new->other->webservices->web service client menu.

    I elected to generate the client code based upon the WSDL URL.

    Code was generated.

    However, when I run the application I get the following error:

    Nov 28, 2006 12:51:18 PM org.codehaus.xfire.transport.local.LocalChannel getService
    INFO: Unable to locate ‘EchoService’ in ServiceRegistry
    Nov 28, 2006 12:51:19 PM org.codehaus.xfire.handler.DefaultFaultHandler invoke
    INFO: Fault occurred!

    So.. What am I missing? How does the client find the ServiceRegistry? Where is the ServiceRegistry? Why does the generated code not find said ServiceRegistry or the contents thereof? ❓

    #262785 Reply

    Brian Fernandes
    Moderator

    I think you may have used the wrong wizard to generate your client – you used the WTP wizard instead of the MyEclipse wizard.

    Try File > New > Other > MyEclipse > Web Services > Web Service Client.

    The WTP wizard you used is Axis based and will not work. Ordinarily the WTP wizards are hidden, did you enable the WTP-Extras and / or WTP (Deprecated) capabilities by any chance?

    Do let us know how it goes.

    #263045 Reply

    Hi,

    I am in the same context than the top message

    I have create a test web service with the xfire myeclipse wizard (the same as in the myeclipse quickstart)

    I tested with the myeclipse web service browser
    http://localhost:8080/HelloWorldWebService/services/WSTest?WSDL

    here’s the code generated for the xfire client

    
    
    package test2;
    
    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 WSTestClient {
    
        private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
    
        private HashMap endpoints = new HashMap();
    
        private Service service0;
    
        public WSTestClient() {
            create0();
            Endpoint WSTestPortTypeLocalEndpointEP = service0.addEndpoint(
                    new QName("http://test", "WSTestPortTypeLocalEndpoint"),
                    new QName("http://test", "WSTestPortTypeLocalBinding"),
                    "xfire.local://WSTest");
            endpoints.put(new QName("http://test", "WSTestPortTypeLocalEndpoint"),
                    WSTestPortTypeLocalEndpointEP);
            Endpoint WSTestHttpPortEP = service0.addEndpoint(new QName(
                    "http://test", "WSTestHttpPort"), new QName("http://test",
                    "WSTestHttpBinding"),
                    "http://localhost:8080/HelloWorldWebService/services/WSTest");
            endpoints.put(new QName("http://test", "WSTestHttpPort"),
                    WSTestHttpPortEP);
        }
    
        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() {
            TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance()
                    .getXFire().getTransportManager());
            HashMap props = new HashMap();
            props.put("annotations.allow.interface", true);
            AnnotationServiceFactory asf = new AnnotationServiceFactory(
                    new Jsr181WebAnnotations(), tm, new AegisBindingProvider(
                            new JaxbTypeRegistry()));
            asf.setBindingCreationEnabled(false);
            service0 = asf.create((test2.WSTestPortType.class), props);
            {
                AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                        new QName("http://test", "WSTestHttpBinding"),
                        "http://schemas.xmlsoap.org/soap/http");
            }
            {
                AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                        new QName("http://test", "WSTestPortTypeLocalBinding"),
                        "urn:xfire:transport:local");
            }
        }
    
        public WSTestPortType getWSTestPortTypeLocalEndpoint() {
            return ((WSTestPortType) (this).getEndpoint(new QName("http://test",
                    "WSTestPortTypeLocalEndpoint")));
        }
    
        public WSTestPortType getWSTestPortTypeLocalEndpoint(String url) {
            WSTestPortType var = getWSTestPortTypeLocalEndpoint();
            org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
            return var;
        }
    
        public WSTestPortType getWSTestHttpPort() {
            return ((WSTestPortType) (this).getEndpoint(new QName("http://test",
                    "WSTestHttpPort")));
        }
    
        public WSTestPortType getWSTestHttpPort(String url) {
            WSTestPortType var = getWSTestHttpPort();
            org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
            return var;
        }
    
        public static void main(String[] args) {
    
            WSTestClient client = new WSTestClient();
    
            //create a default service endpoint
            WSTestPortType wSTestPortType = client.getWSTestPortTypeLocalEndpoint();
    
            //TODO: Add custom client code here
            //
            System.out.println(wSTestPortType.example("salut"));
    
            System.out.println("test client completed");
            System.exit(0);
        }
    
    }
    
    
    
    
    package test2;
    
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebResult;
    import javax.jws.WebService;
    import javax.jws.soap.SOAPBinding;
    
    @WebService(name = "WSTestPortType", targetNamespace = "http://test")
    @SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
    public interface WSTestPortType {
    
        @WebMethod(operationName = "example", action = "")
        @WebResult(name = "out", targetNamespace = "http://test")
        public String example(
                @WebParam(name = "in0", targetNamespace = "http://test")
                String in0);
    
    }
    
    

    I get this message

    5 déc. 2006 15:28:54 org.codehaus.xfire.transport.local.LocalChannel getService
    INFO: Unable to locate ‘WSTest’ in ServiceRegistry
    5 déc. 2006 15:28:54 org.codehaus.xfire.handler.DefaultFaultHandler invoke
    INFO: Fault occurred!
    org.codehaus.xfire.fault.XFireFault: Could not find a service to invoke.
    at org.codehaus.xfire.handler.LocateBindingHandler.invoke(LocateBindingHandler.java:39)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
    at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
    at org.codehaus.xfire.transport.local.LocalChannel.sendViaNewChannel(LocalChannel.java:172)
    at org.codehaus.xfire.transport.local.LocalChannel.send(LocalChannel.java:99)
    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: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 $Proxy8.example(Unknown Source)
    at test2.WSTestClient.main(WSTestClient.java:117)
    5 déc. 2006 15:28:54 org.codehaus.xfire.handler.DefaultFaultHandler sendToDeadLetter
    GRAVE: Could not find service.
    org.codehaus.xfire.fault.XFireFault: Could not find a service to invoke.
    at org.codehaus.xfire.handler.LocateBindingHandler.invoke(LocateBindingHandler.java:39)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
    at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
    at org.codehaus.xfire.transport.local.LocalChannel.sendViaNewChannel(LocalChannel.java:172)
    at org.codehaus.xfire.transport.local.LocalChannel.send(LocalChannel.java:99)
    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: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 $Proxy8.example(Unknown Source)
    at test2.WSTestClient.main(WSTestClient.java:117)
    null
    test client completed

    any idea ?

    Kind regards,

    Guillaume

    #263052 Reply

    BTW, the shorter client code provided in the quickstart is working.

    
    
    package test2;
    
    import java.net.MalformedURLException;
    
    import org.codehaus.xfire.XFireFactory;
    import org.codehaus.xfire.client.XFireProxyFactory;
    import org.codehaus.xfire.service.Service;
    import org.codehaus.xfire.service.binding.ObjectServiceFactory;
    
    import test.IWSTest;
    
    public class WSTestClientFromTutorial {
    
         public static void main(String[] args) { 
                Service srvcModel = new 
                ObjectServiceFactory().create(test.IWSTest.class); 
                XFireProxyFactory factory =  
                   new XFireProxyFactory(XFireFactory.newInstance().getXFire()); 
                String helloWorldURL = 
                   "http://localhost:8080/HelloWorldWebService/services/WSTest"; 
                try { 
                   IWSTest srvc = (IWSTest)factory.create(srvcModel, helloWorldURL); 
                   String result = srvc.example("hello world 2 HelLo"); 
                   System.out.print(result); 
                } catch (MalformedURLException e) { 
                   e.printStackTrace(); 
                }
              } 
        
    
    }
    
    
    
    #263057 Reply

    Brian Fernandes
    Moderator

    Guillaume,

    A few questions
    1) How did you generate the service – did you use a top down or bottom up approach?
    2) How did you generate the client – did you use the Client wizard or did you choose to generate a test client along with the service (if you used top down)

    Is it possible for you to give me the WSDL file you used to generate this service / client? You can paste it here if not too large or you can email it to support@genuitec.com ATTN Brian.

    Best regards,

    #263075 Reply

    Hi Brian,

    I’ve used a bottom-up approach with the myeclipse wizard.
    Cf. http://myeclipseide.com/enterpriseworkbench/help/index.jsp?topic=/com.genuitec.myeclipse.doc/html/quickstarts/webservices/index.html

    Also I am using myeclipse xfire libs with myeclipse 5.1

    I’ve started apache and deployed the app using myeclipse deployment tools.

    Then I am using the WSDL generated by myeclipse xfire libs using the URL
    http://localhost:8080/HelloWorldWebService/services/WSTest?WSDL

    So after I’ve used the xfire myeclipse wizard with the previous URL

    
       <?xml version="1.0" encoding="UTF-8" ?> 
     <wsdl:definitions targetNamespace="http://test" xmlns:tns="http://test" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
     <wsdl:types>
     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test">
     <xsd:element name="example">
     <xsd:complexType>
     <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" /> 
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
     <xsd:element name="exampleResponse">
     <xsd:complexType>
     <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" /> 
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      </xsd:schema>
      </wsdl:types>
     <wsdl:message name="exampleRequest">
      <wsdl:part name="parameters" element="tns:example" /> 
      </wsdl:message>
     <wsdl:message name="exampleResponse">
      <wsdl:part name="parameters" element="tns:exampleResponse" /> 
      </wsdl:message>
     <wsdl:portType name="WSTestPortType">
     <wsdl:operation name="example">
      <wsdl:input name="exampleRequest" message="tns:exampleRequest" /> 
      <wsdl:output name="exampleResponse" message="tns:exampleResponse" /> 
      </wsdl:operation>
      </wsdl:portType>
     <wsdl:binding name="WSTestHttpBinding" type="tns:WSTestPortType">
      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
     <wsdl:operation name="example">
      <wsdlsoap:operation soapAction="" /> 
     <wsdl:input name="exampleRequest">
      <wsdlsoap:body use="literal" /> 
      </wsdl:input>
     <wsdl:output name="exampleResponse">
      <wsdlsoap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
     <wsdl:service name="WSTest">
     <wsdl:port name="WSTestHttpPort" binding="tns:WSTestHttpBinding">
      <wsdlsoap:address location="http://localhost:8080/HelloWorldWebService/services/WSTest" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
    
    #263181 Reply

    Brian Fernandes
    Moderator

    Guillaume,

    Can you change the following code in the main routine of your client

    
    //create a default service endpoint
    WSTestPortType wSTestPortType = client.getWSTestPortTypeLocalEndpoint(); 
    

    to

    
    //create a default service endpoint
    WSTestPortType wSTestPortType = client.getWSTestHttpPort(); 
    

    This is a bug in the generator which used the local endpoint instead of the actual service endpoint. It has been fixed and will be available in 5.1.1.

    Sorry for the inconvenience caused, could you let us know if that solves your problem?

    #263208 Reply

    Hi Brian,

    Yes, it works fine now. thanks.

    I’ll do extra testing/coding making more complex webservices

    Cheers,

    Guillaume

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: [Closed] Problem with web service client generator

You must be logged in to post in the forum log in