4 Replies Latest reply on Nov 5, 2007 3:11 AM by Richard Opalka

    Web Service client side

    Giuseppe Moscardelli Newbie

      Hi, I'd like making a web service client that invokes a web service deployed in jbossws.
      For this client web service I must not use the stub classes generated with wsconsume, where can I get a tutorial?
      Where can I find a client example created without the stub classes?
      Thanks, bye bye.

        • 1. Re: Web Service client side
          Richard Opalka Master

          Hi,

          you can use javax.xml.ws.Dispatch to invoke webservices dynamically without creating stubs. Good starting point for you could be JAX-WS JSR specification document.

          Richard

          • 2. Re: Web Service client side
            Giuseppe Moscardelli Newbie

            Hi, I've searched but I don't uderstand much. I have the service name, the operation name and parameters of the operation and I want invoke the operation.
            I've found this code of an axis dynamic client, I've created it but when I meke the call to web service I receive this error:

            Exception in thread "main" AxisFault
             faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
             faultSubcode:
             faultString: For input string: ""
             faultActor:
             faultNode:
             faultDetail:
             {http://xml.apache.org/axis/}stackTrace:For input string: ""
            .....
            .....
            

            in the client while jboss give me this error:
            17:13:27,275 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
            org.jboss.ws.core.CommonSOAPFaultException: Endpoint {http://tesi/}TesiPort does
             not contain operation meta data for: fattoriale
             at org.jboss.ws.core.server.ServiceEndpointInvoker.getDispatchDestinatio
            n(ServiceEndpointInvoker.java:457)
             at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
            tInvoker.java:176)
             at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
            dlerImpl.java:408)
            ....
            ....
            ....


            My client code is the following:
             String endpoint = "http://127.0.0.1:8080/Tesi";
             Service service = new Service();
             Call call = (Call) service.createCall();
             call.setTargetEndpointAddress(new java.net.URL(endpoint));
             call.setOperationName("fattoriale");
             call.addParameter("arg0", XMLType.XSD_INT, ParameterMode.IN);
             call.setReturnType(XMLType.XSD_DOUBLE);
             Object[] param = new Object[] {new Integer(6)};
             Double risultato = (Double)call.invoke(param);
             System.out.println(risultato);
            


            How do I have to modify in this code?

            I've looked for jax-ws but I don't understand anything.
            Thanks, bye bye.

            • 3. Re: Web Service client side
              Giuseppe Moscardelli Newbie

              Hi I've tryed to write this client but it doesn't work:

              import javax.xml.namespace.QName;
              import javax.xml.rpc.Call;
              import javax.xml.rpc.ParameterMode;
              import javax.xml.rpc.Service;
              import javax.xml.rpc.ServiceException;
              import javax.xml.rpc.ServiceFactory;
              import javax.xml.rpc.encoding.XMLType;
              
              public class ClientProva {
              
              public static void main(String[] args) throws ServiceException, RemoteException{
              
              QName serviceName = new QName("Tesi");
               ServiceFactory factory = ServiceFactory.newInstance();
               Service service = factory.createService(serviceName);
              
               Call call = service.createCall();
               call.setTargetEndpointAddress("http://localhost:8080/Tesi/services/port");
               QName operationName = new QName("getNumberOfRequest");
               call.setOperationName(operationName);
               call.addParameter(
               "arg0", // parameter name
               XMLType.XSD_STRING, // parameter XML type QName
               String.class, // parameter Java type class
               ParameterMode.IN); // parameter mode
               call.setReturnType(XMLType.XSD_INT);
               call.setProperty(
               Call.OPERATION_STYLE_PROPERTY,
               "wrapped");
               Object[] actualArgs = {"fattoriale"};
               Integer response = (Integer) call.invoke(actualArgs);
               System.out.println("response = " + response);
              }
              }
              


              I've ONLY service name, operation name and endpoint address.
              When I run the client jboss give me this output:
              11:21:24,850 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
              org.jboss.ws.core.CommonSOAPFaultException: Endpoint {http://tesi/}TesiPort does
               not contain operation meta data for: getNumberOfRequest
               at org.jboss.ws.core.server.ServiceEndpointInvoker.getDispatchDestinatio
              n(ServiceEndpointInvoker.java:457)
               at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
              tInvoker.java:176)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
              dlerImpl.java:408)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
              lerImpl.java:272)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
              .java:189)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
              HandlerImpl.java:122)
               at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java
              :84)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
              lter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
              alve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
              alve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
              yAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
              e.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
              ava:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
              ava:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
              onnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
              ve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
              a:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
              :844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
              ss(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
              7)
               at java.lang.Thread.run(Thread.java:595)
              11:21:24,888 ERROR [SOAPFaultHelperJAXRPC] SOAP request exception
              javax.xml.rpc.soap.SOAPFaultException: Endpoint {http://tesi/}TesiPort does not
              contain operation meta data for: getNumberOfRequest
               at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.exceptionToFaultMessag
              e(SOAPFaultHelperJAXRPC.java:189)
               at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(
              SOAPFaultHelperJAXWS.java:157)
               at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessage
              FromException(SOAP11BindingJAXWS.java:104)
               at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBindin
              g.java:645)
               at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
              tInvoker.java:277)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
              dlerImpl.java:408)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
              lerImpl.java:272)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
              .java:189)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
              HandlerImpl.java:122)
               at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java
              :84)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
              lter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
              alve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
              alve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
              yAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
              e.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
              ava:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
              ava:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
              onnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
              ve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
              a:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
              :844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
              ss(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
              7)
               at java.lang.Thread.run(Thread.java:595)
              11:21:24,938 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
              org.jboss.ws.core.CommonSOAPFaultException: Endpoint {http://tesi/}TesiPort does
               not contain operation meta data for: getNumberOfRequest
               at org.jboss.ws.core.server.ServiceEndpointInvoker.getDispatchDestinatio
              n(ServiceEndpointInvoker.java:457)
               at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpoin
              tInvoker.java:176)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
              dlerImpl.java:408)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
              lerImpl.java:272)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
              .java:189)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
              HandlerImpl.java:122)
               at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java
              :84)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
              lter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
              alve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
              alve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
              yAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
              e.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
              ava:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
              ava:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
              onnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
              ve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
              a:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
              :844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
              ss(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
              7)
               at java.lang.Thread.run(Thread.java:595)
              11:21:24,981 ERROR [SOAPFaultHelperJAXRPC] SOAP request exception
              javax.xml.rpc.soap.SOAPFaultException: Endpoint {http://tesi/}TesiPort does not
              contain operation meta data for: getNumberOfRequest
               at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.exceptionToFaultMessag
              e(SOAPFaultHelperJAXRPC.java:189)
               at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(
              SOAPFaultHelperJAXWS.java:157)
               at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessage
              FromException(SOAP11BindingJAXWS.java:104)
               at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBindin
              g.java:645)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHan
              dlerImpl.java:430)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHand
              lerImpl.java:272)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl
              .java:189)
               at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(Request
              HandlerImpl.java:122)
               at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java
              :84)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
              lter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
              icationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
              ilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
              alve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
              alve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
              yAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
              e.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
              ava:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
              ava:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
              onnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
              ve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
              a:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
              :844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
              ss(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
              7)
               at java.lang.Thread.run(Thread.java:595)
              


              Instead the client give me this error:
              Exception in thread "main" AxisFault
               faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
               faultSubcode:
               faultString: Endpoint {http://tesi/}TesiPort does not contain operation meta data for: getNumberOfRequest
               faultActor:
               faultNode:
               faultDetail:
               {http://xml.apache.org/axis/}stackTrace:Endpoint {http://tesi/}TesiPort does not contain operation meta data for: getNumberOfRequest
               at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
               at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
               at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
               at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.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 ClientProva.main(ClientProva.java:48)
              
               {http://xml.apache.org/axis/}hostname:server
              
              Endpoint {http://tesi/}TesiPort does not contain operation meta data for: getNumberOfRequest
               at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
               at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
               at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
               at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
               at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
               at com.sun.org.apache.xerces.internal.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 ClientProva.main(ClientProva.java:48)
              


              I've tryed everything how can I create this holy dynamic client having only service Name, operation Name and enpoint address?

              Thanks, bye bye.

              • 4. Re: Web Service client side
                Richard Opalka Master

                Hi,

                you must set up SOAP action too

                Richard