10 Replies Latest reply on May 30, 2006 4:25 PM by thomas.diesler

    Standalone client for JBoss hosted Web Service [using JBossW

    vink

      hello,

      I'm using JBoss 4.0.4.GA & trying to deploy an ejb as an web service which was done.

      But, now I want to communicate with that web service as a client which is not deployed on JBoss. How can I do this?

      Does JBossWS provides support for this.
      Is there any sample available to excercise it?

      Looking forward to suggestions..

      regards

      Vinay

        • 1. Re: Standalone client for JBoss hosted Web Service [using JB
          sonalraj

          Yes,

          You can have a DII (Dynamic Invocation Interface) client or Static stub generated client .

          'Jboss Getting started' is a good documentation for this,
          http://docs.jboss.org/jbossas/getting_started/v4/html/ws.html#d0e1467

          --
          Sonal

          • 2. Re: Standalone client for JBoss hosted Web Service [using JB
            vink

            hello,

            Thanks for the reply. I've tried the sample code listed there, but it results in the following failure..

            Please suggest.


            log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.JSR109ClientMetaDataBuilder).
            log4j:WARN Please initialize the log4j system properly.
            Exception in thread "main" java.lang.NoSuchFieldError: fFeatures
            at org.jboss.xb.binding.parser.xni.XniJBossXBParser$ParserConfiguration.configurePipeline(XniJBossXBParser.java:459)
            at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
            at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
            at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.jboss.xb.binding.parser.xni.XniJBossXBParser.parse(XniJBossXBParser.java:192)
            at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:151)
            at org.jboss.ws.metadata.config.WSConfigFactory.parseWithObjectModelFactory(WSConfigFactory.java:91)
            at org.jboss.ws.metadata.ClientEndpointMetaData.getClientConfig(ClientEndpointMetaData.java:94)
            at org.jboss.ws.metadata.ClientEndpointMetaData.getHandlers(ClientEndpointMetaData.java:124)
            at org.jboss.ws.metadata.ClientEndpointMetaData.toString(ClientEndpointMetaData.java:158)
            at java.lang.String.valueOf(String.java:2577)
            at java.lang.StringBuilder.append(StringBuilder.java:116)
            at org.jboss.ws.metadata.ServiceMetaData.toString(ServiceMetaData.java:422)
            at java.lang.String.valueOf(String.java:2577)
            at java.lang.StringBuilder.append(StringBuilder.java:116)
            at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:127)
            at org.jboss.ws.metadata.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:78)
            at org.jboss.ws.jaxrpc.ServiceImpl.(ServiceImpl.java:96)
            at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
            at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128)
            at client.DesktopManagementClient.testNonJ2EE(DesktopManagementClient.java:56)
            at client.DesktopManagementClient.main(DesktopManagementClient.java:46)

            • 3. Re: Standalone client for JBoss hosted Web Service [using JB
              sonalraj


              Can you paste your client code ?
              And i think by initializing the root logger the log4j warning will be resolved.

              --
              Sonal.

              • 4. Re: Standalone client for JBoss hosted Web Service [using JB
                vink

                I've pasted only the basic code which is mentioned there to run the client.
                Please see below.

                public class DesktopManagementClient
                {

                public static final String SERVICE_NAME = "DesktopManagementAPI";
                public static final String TARGET_NAMESPACE = "http://www.me.com/cms/desktopmanagement";
                public static final String TARGET_ENDPOINT_ADDRESS = "http://localhost:8080/DesktopManagementAPI/DesktopManagementAPIImpl?wsdl";


                /**
                * @param args
                */
                public static void main (String[] args)
                throws Exception
                {
                DesktopManagementClient client = new DesktopManagementClient();
                // client.testJNDI();
                // client.testRPC();
                // client.testDynamicInvocation();
                // client.testDynamicInvocationWithWSDL();
                client.testNonJ2EE();
                }


                public void testNonJ2EE ()
                throws MalformedURLException, ServiceException, RemoteException
                {
                URL url = new URL(TARGET_ENDPOINT_ADDRESS);
                QName qname = new QName(TARGET_NAMESPACE, SERVICE_NAME);

                ServiceFactory factory = ServiceFactory.newInstance();
                Service service = factory.createService(url, qname);

                DesktopManagementAPIEndpoint port = (DesktopManagementAPIEndpoint) service.getPort(DesktopManagementAPIEndpoint.class);

                String name = port.getName();
                System.out.println("Name: " + name);

                for (int i = 0; i < 100; i++)
                {
                port.setName(name + "." + i);
                System.out.println("New name: " + port.getName());
                }

                }

                }

                • 5. Re: Standalone client for JBoss hosted Web Service [using JB
                  sonalraj

                  Hey...Don't know what is the" fFeatures " field,

                  This link gives very simple example on DII client.
                  http://wiki.jboss.org/wiki/Wiki.jsp?page=WS4EEClientDII

                  Hope this will help you!

                  --
                  Sonal.

                  • 6. Re: Standalone client for JBoss hosted Web Service [using JB
                    vink

                    Just found a similar problem in "http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3884516".

                    Mention that the version of Xerces parser is causing problem. The solution is proposing the use of Xerces 2.7.0.

                    • 7. Re: Standalone client for JBoss hosted Web Service [using JB
                      acxjbertr

                       

                      I'm using JBoss 4.0.4.GA & trying to deploy an ejb as an web service which was done.


                      Did you use wstools to generate the necessary artifacts? If so, can you explain more about how? All the JBoss tutorials that I have found only cover web services as servlets. Thanks!

                      • 8. Re: Standalone client for JBoss hosted Web Service [using JB
                        vink

                        Even if your client app is a servlet, if you want to access web service you need to generate artifacts. As these artifacts will enable you to communicate with web service.

                        The ant task available with JBoss 4.0.4.GA is not working at my system. So, I've used the commandline utility for generation.

                        // Command line generation, please set classpath first
                        set path=%path%;%JBOSS_HOME%/bin
                        wstools -cp bin -config resource/wstools-config.xml -dest src

                        If you browse through the JBossWS userguide document you will find the respective sections with wstools-config.xml, but it also needs the wsdl for client generation. So, first I've packaged my sessions beans in .ejb3, deployed them on server & then walk through the browser to retreive the wsdl of my web service. Then using the above scripts, required artifacts would be generated including jaxrpc-mapping.xml.

                        • 9. Re: Standalone client for JBoss hosted Web Service [using JB
                          vink

                          Still the non J2EE client is not running, it is raising the same exception which it is raising earlier.

                          Is there anybody who has tested this scenario on Jboss AS 4.0.4.GA. I think it is not yet in usable state for the web service clients.

                          • 10. Re: Standalone client for JBoss hosted Web Service [using JB
                            thomas.diesler

                            Please note that standard JAXRPC DII clients do not have a notion of jaxrpc-mapping.xml. In other words they cannot know (or have to rely on guesswork) how to map wsdl constructs to java.

                            This is why I recommend (a tiny) jboss on the client side. Alternatively you will have to use the propriatary ServiceFactoryImpl API.

                            http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWSFAQClientModel

                            http://fisheye.jboss.com/viewrep/JBossWS/trunk/src/main/java/org/jboss/ws/jaxrpc/ServiceFactoryImpl.java?r=275

                            I also appologize for not making this clear in the DII section of the user guide. It will be updated with jbossws-1.0.1 shortly