1 Reply Latest reply on Apr 8, 2007 6:41 AM by shuping chen

    need some help for session bean web service

    shuping chen Newbie

      when i develope session bean ws, i encountered the following problem:

      Exception in thread "main" java.lang.IllegalArgumentException: Cannot obtain wsdl service: {http://stateless.session.examples}ejb3test
      at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaDataInternal(JAXWSClientMetaDataBuilder.java:126)
      at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:80)
      at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.(ServiceDelegateImpl.java:109)
      at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:61)
      at javax.xml.ws.Service.(Unknown Source)
      at javax.xml.ws.Service.create(Unknown Source)
      at examples.session.ws.JAXWSClient.main(JAXWSClient.java:36)

      package examples.session.ws;
      
      import java.net.URL;
      import javax.xml.namespace.QName;
      import javax.xml.ws.Service;
      
      import examples.session.stateless.HelloBean;
      
      
      
      /**
       * This is an example of a standalone JAX-WS client. To compile, it requires
       * some XML artifacts to be generated from the service?s WSDL. This is done in
       * the build file.
       *
       * The mapped XML classes used here are 1. the HelloBean port type class (this
       * is NOT the bean impl. class!) 2. the Greeter service class
       */
      public class JAXWSClient {
       static String host = "localhost";
      
       static String portType = "HelloBean";
      
       static String serviceName = "ejb3test";
      
       static String serviceEndpointAddress = "http://" + host + ":8080/"
       + serviceName;
      
       static String nameSpace = "http://stateless.session.examples";
      
       public static void main(String[] args) throws Exception {
       URL wsdlLocation = new URL(serviceEndpointAddress + "/" + portType
       + "?WSDL");
       QName serviceNameQ = new QName(nameSpace, serviceName);
       // dynamic service usage
       Service service = Service.create(wsdlLocation, serviceNameQ);
       HelloBean firstGreeterPort = service.getPort(HelloBean.class);
       System.out.println("1: " + firstGreeterPort.hello());
       // static service usage
      // Greeter greeter = new Greeter();
      // HelloBean secondGreeterPort = greeter.getGreeterPort();
      // System.out.println("2: " + secondGreeterPort.hello());
       }
      }


        • 1. Re: need some help for session bean web service
          shuping chen Newbie

          when i use the axis to rewrite my ws client, i have another problem:

          AxisFault
          faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
          faultSubcode:
          faultString: org.xml.sax.SAXParseException: Premature end of file.
          faultActor:
          faultNode:
          faultDetail:
          {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
          at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
          at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
          at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
          at javax.xml.parsers.SAXParser.parse(Unknown Source)
          at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
          at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
          at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
          at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
          at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
          at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
          at org.apache.axis.client.Call.invoke(Call.java:2767)
          at org.apache.axis.client.Call.invoke(Call.java:2443)
          at org.apache.axis.client.Call.invoke(Call.java:2366)
          at org.apache.axis.client.Call.invoke(Call.java:1812)
          at csp.jx.ws.test.TestByJNDI.main(TestByJNDI.java:27)

          {http://xml.apache.org/axis/}hostname:lanneret

          org.xml.sax.SAXParseException: Premature end of file.
          at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
          at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
          at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
          at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
          at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
          at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
          at org.apache.axis.client.Call.invoke(Call.java:2767)
          at org.apache.axis.client.Call.invoke(Call.java:2443)
          at org.apache.axis.client.Call.invoke(Call.java:2366)
          at org.apache.axis.client.Call.invoke(Call.java:1812)
          at csp.jx.ws.test.TestByJNDI.main(TestByJNDI.java:27)
          Caused by: org.xml.sax.SAXParseException: Premature end of file.
          at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
          at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
          at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
          at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
          at javax.xml.parsers.SAXParser.parse(Unknown Source)
          at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
          at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
          ... 9 more


          my client code :

          package csp.jx.ws.test;
          
          import java.net.MalformedURLException;
          import java.net.URL;
          import java.rmi.RemoteException;
          
          import javax.xml.namespace.QName;
          import javax.xml.rpc.ServiceException;
          
          import org.apache.axis.client.Call;
          import org.apache.axis.client.Service;
          
          public class TestByJNDI {
          
           /**
           * @param args
           */
           public static void main(String[] args) {
           try {
           String endpoint = "http://localhost:8080/ejb3test/HelloBean";
           Service service = new Service();
           Call call = (Call)service.createCall();
          
           call.setTargetEndpointAddress(new URL(endpoint));
           call.setOperationName(new QName("http://stateless.session.examples","hello"));
          
           String ret = (String)call.invoke(new Object[]{});
          
           System.out.println(ret);
           } catch (MalformedURLException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
           } catch (ServiceException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
           } catch (RemoteException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
           }
           }
          
          }