3 Replies Latest reply on Jun 25, 2010 3:23 PM by luizsync

    Web Service Cliente

    luizsync

      Good day!

       

      I have:

           JBoss 5.1 GA

           JDK 1.6

       

      I got this sample and I'm trying to repeat:

      http://www.codeproject.com/KB/java/webservice-for-jboss.aspx?msg=3252357

       

       

      I have problems about Web Service and I don't know how I can solve this problem:

       

      java.rmi.RemoteException: Call invocation failed; nested exception is:
          java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
          at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:535)
          at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:275)
          at web_service_teste.web_teste.main(web_teste.java:40)
      Caused by: java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
          at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:445)
          at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:87)
          at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:169)
          at org.jboss.ws.core.CommonSOAP11Binding.createMessage(CommonSOAP11Binding.java:57)
          at org.jboss.ws.core.CommonSOAPBinding.bindRequestMessage(CommonSOAPBinding.java:157)
          at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:290)
          at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:516)
          ... 2 more

       

       

      If someone know where my mistake, please help me!

      I'm trying to assemble this Web Service Cliente:

       

      //===============================================================

      package web_service_teste;

       

      import javax.xml.rpc.Call;
      import javax.xml.rpc.Service;
      import javax.xml.rpc.ServiceFactory;
      import javax.xml.rpc.ParameterMode;
      import javax.xml.namespace.QName;

       

      public class web_teste
      {
          public static void main(String[] argv)
          {
              try
              {
                  String NS_XSD = "http://www.w3.org/2001/XMLSchema" ;
                  ServiceFactory factory = ServiceFactory.newInstance() ;


                  Service service = factory.createService(new QName("http://localhost:8080/web_service/", "HelloWorldService")) ;

             
                  Call call = service.createCall(new QName("http://localhost:8080/web_service/", "HelloWorldService")) ;

       

                  call.setTargetEndpointAddress("http://localhost:8080/web_service/wsdl/HelloWorld.wsdl") ;

       

                  call.setOperationName( new QName("http://localhost:8080/web_service/", "sayHello")) ;

       

                 
                  QName QNAME_TYPE_STRING = new QName(NS_XSD, "string") ;
                  call.setReturnType(QNAME_TYPE_STRING);

       

                  call.addParameter("arg0", QNAME_TYPE_STRING, ParameterMode.IN) ;
                  String[] params = { "teste" };

       

                  String result = (String) call.invoke(params);
                  System.out.println(" --- " + result);
              }
              catch (Exception e)
              {
                  e.printStackTrace();
              }
          }
      }

      //===============================================================

       

       

      The Web Service is working fine. It is the sample from Eclipse. I have the wsdl in place and I tested it with Web Service Explorer:

       

      //===============================================================

      package org.jboss.samples.webservices;

       

      import javax.jws.WebMethod;
      import javax.jws.WebService;


      @WebService
      public class HelloWorld {

       

          @WebMethod
          public String sayHello(String name) {
              System.out.println("Hello: " + name);
              return "Hello " + name + "!";
          }
      }

      //===============================================================

       

       

      wsdl:

       

       

      //=============================================================

      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions targetNamespace="http://webservices.samples.jboss.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservices.samples.jboss.org" xmlns:intf="http://webservices.samples.jboss.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <!--WSDL created by Apache Axis version: 1.4
      Built on Apr 22, 2006 (06:55:48 PDT)-->
      <wsdl:types>
        <schema elementFormDefault="qualified" targetNamespace="http://webservices.samples.jboss.org" xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="sayHello">
          <complexType>
           <sequence>
            <element name="name" type="xsd:string"/>
           </sequence>
          </complexType>
         </element>
         <element name="sayHelloResponse">
          <complexType>
           <sequence>
            <element name="sayHelloReturn" type="xsd:string"/>
           </sequence>
          </complexType>
         </element>
        </schema>
      </wsdl:types>

       

         <wsdl:message name="sayHelloResponse">

       

            <wsdl:part element="impl:sayHelloResponse" name="parameters"/>

       

         </wsdl:message>

       

         <wsdl:message name="sayHelloRequest">

       

            <wsdl:part element="impl:sayHello" name="parameters"/>

       

         </wsdl:message>

       

         <wsdl:portType name="HelloWorld">

       

            <wsdl:operation name="sayHello">

       

               <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/>

       

               <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/>

       

            </wsdl:operation>

       

         </wsdl:portType>

       

         <wsdl:binding name="HelloWorldSoapBinding" type="impl:HelloWorld">

       

            <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

       

            <wsdl:operation name="sayHello">

       

               <wsdlsoap:operation soapAction=""/>

       

               <wsdl:input name="sayHelloRequest">

       

                  <wsdlsoap:body use="literal"/>

       

               </wsdl:input>

       

               <wsdl:output name="sayHelloResponse">

       

                  <wsdlsoap:body use="literal"/>

       

               </wsdl:output>

       

            </wsdl:operation>

       

         </wsdl:binding>

       

         <wsdl:service name="HelloWorldService">

       

            <wsdl:port binding="impl:HelloWorldSoapBinding" name="HelloWorld">

       

               <wsdlsoap:address location="http://localhost:8080/web_service/services/HelloWorld"/>

       

            </wsdl:port>

       

         </wsdl:service>

       

      </wsdl:definitions>

      //==============================================================================

        • 1. Re: Web Service Cliente
          foxsterling

          https://jira.jboss.org/browse/JBWS-2671

           

          From that (Closed and not fixed) defect, looks like it is an issue with Java 1.6. I've run into the same problem and I'm looking for some solution that wont have me changing my code since I've been developing with 1.6 API's for some time now. Maybe the solution is to use a different API, such as Apache.

          • 2. Re: Web Service Cliente
            jaikiran
            • 3. Re: Web Service Cliente
              luizsync

              Thanks for your answer!

               

              I solved the question with another tutorial:

              http://www.personati.com/artigos/web_services.pdf

               

              //===========================================================

              package web_service_teste;

               

              import org.apache.axis.client.Call;
              import org.apache.axis.client.Service;

               

              public class web_teste
              {
                  public static void main(String[] args)
                  {
                      try
                      {
                          String urlWS = "http://localhost:8080/web_service/services/HelloWorld";
                          Object[] params = { "ooo" };
                          Service service = new Service();
                          Call call = (Call) service.createCall();
                          call.setOperationStyle(org.apache.axis.constants.Style.WRAPPED);
                          call.setOperationUse(org.apache.axis.constants.Use.LITERAL);
                          call.setTargetEndpointAddress(urlWS);
                          call.setOperationName("sayHello");
                          String ret = (String) call.invoke(params);
                          System.out.println("Resultado: " + ret);
                      }
                      catch (Exception ex)
                      {
                          ex.printStackTrace();
                      }
                  }
              }

              //======================================================

               

              We can not forget the jars:

               

              axis.jar

              jaxrpc.jar

              commons-logging.jar

              commons-discovery.jar

              saaj.jar

              wsdl4j.jar