2 Replies Latest reply: Aug 16, 2012 12:50 AM by 904010 RSS

    Getting .ServiceException while invoking a web service from a client

    904010
      I created a web service and then created a web service client from wsdl in eclipse. I am getting the following error when trying to call the web service from client.

      javax.xml.rpc.ServiceException: There is no stub implementation for the interface: examples.ejb.ejb20.basic.statelessSession.TraderBeanService

      Please find the files here -

      wsdl - http://www.sourcepod.com/uneksu63-9627
      Trade.java - http://www.sourcepod.com/mltizr21-9628
      TradeResult.java - http://www.sourcepod.com/npledh19-9629
      TradeResultService - http://www.sourcepod.com/hbjevm45-9630
      TradeResultServiceLocator.java - http://www.sourcepod.com/mrpagh85-9631
      TradeResultSoapBindingStub.java - http://www.sourcepod.com/zjrkjv91-9632
      package examples.ejb.ejb20.basic.statelessSession;
      
      import javax.xml.ws.WebServiceRef;
      import javax.xml.namespace.QName;
      
      
      public class HelloClient {
          @WebServiceRef(wsdlLocation="http://localhost:7001/webservice/services/TraderBean?wsdl")
          String url = "http://localhost:7001/webservice/services/TraderBean?wsdl";
               QName qname = new QName("http://statelessSession.basic.ejb20.ejb.examples", "TraderBeanService");
      
      
          public static void main(String[] args) {
              try {
                  HelloClient client = new HelloClient();
                  client.doTest(args);
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }
      
          public void doTest(String[] args) {
              try {
                   TraderBeanServiceLocator service = new TraderBeanServiceLocator(url,qname);
                  TraderBean port = (TraderBean) service.getPort(TraderBeanService.class);
                  System.out.println("Invoking the sayHello operation on the port.");
      
      
                  TradeResult response = port.buy("INR", 100);
                  System.out.println(response.getNumberTraded());
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }
      }
      How to solve the stub implementation error?

      Edited by: 901007 on 12 Aug, 2012 10:57 AM
        • 1. Re: Getting .ServiceException while invoking a web service from a client
          user696
          Can you try like this TraderBean port = (TraderBean) service.getPort(); see if that makes any difference.

          Regards,
          Sunil P
          • 2. Re: Getting .ServiceException while invoking a web service from a client
            904010
            That did not work either. There was getPorts() and not getPort() and I used getPorts(). And I am getting the below error,
            java.lang.ClassCastException: java.util.HashMap$KeyIterator

            But when I try like the below,
                @WebServiceRef(wsdlLocation="http://localhost:7001/webservice/services/TraderBean?wsdl")
                String url = "http://localhost:7001/webservice/services/TraderBean?wsdl";
                QName qname = new QName("http://statelessSession.basic.ejb20.ejb.examples", "TraderBeanService");
            
                        TraderBeanServiceLocator service = new TraderBeanServiceLocator();
                        TraderBean port = (TraderBean) service.getPort(TraderBean.class);
                        System.out.println("Invoking the sayHello operation on the port.");
                       
                        TradeResult response = port.buy("INR", 200);
                        System.out.println(response.getNumberTraded());
            I am getting the below error,

            Invoking the sayHello operation on the port.
            AxisFault
            faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
            faultSubcode:
            faultString: java.lang.InstantiationException: examples.ejb.ejb20.basic.statelessSession.TraderBean
            faultActor:
            faultNode:
            faultDetail:
                 {http://xml.apache.org/axis/}hostname:Gopi_Desktop
            java.lang.InstantiationException: examples.ejb.ejb20.basic.statelessSession.TraderBean

            As you can see the statement"Invoking the sayHello operation on the port." is getting printed but after that error is thrown.

            I tried changing it to, TraderBean port = (TraderBean) service.getPort(qname, TraderBeanServiceLocator.class);
            But even this is throwing the same error, java.lang.InstantiationException: examples.ejb.ejb20.basic.statelessSession.TraderBean

            I changed my webservice using Axis2 web service runtime and this time when I try to invoke using client, I am getting the following,

            [WARN] Weblogic's StAX implementation is unsupported and some Axiom features will not work as expected! Please use Woodstox instead.
            Exception in thread "Main Thread" org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException: Error at line:1 col:217 ':' Already got a ':' in name
                 at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
                 at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
                 at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
                 at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
                 at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
                 at examples.ejb.ejb20.basic.statelessSession.TraderBeanStub.addTwoNumbers(TraderBeanStub.java:185)
                 at examples.ejb.ejb20.basic.statelessSession.TestClient.main(TestClient.java:15)

            If you need more details, I can post the steps I did to build it...
            Any help is greately appreciated.

            Edited by: 901007 on 15 Aug, 2012 10:27 PM

            Edited by: 901007 on 15 Aug, 2012 10:49 PM