[jboss-user] [Beginner's Corner] - Web Service Cliente

luiz syncode do-not-reply at jboss.com
Thu Jun 24 13:24:11 EDT 2010


luiz syncode [http://community.jboss.org/people/luizsync] created the discussion

"Web Service Cliente"

To view the discussion, visit: http://community.jboss.org/message/549550#549550

--------------------------------------------------------------
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 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 http://www.w3.org/2001/XMLSchema" ; 
            ServiceFactory factory = ServiceFactory.newInstance() ;

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

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

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

            call.setOperationName( new QName(" http://localhost:8080/web_service/ 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. Is the sample from Eclipse I have the wsdl in place. I test 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 http://webservices.samples.jboss.org" xmlns:apachesoap=" http://xml.apache.org/xml-soap http://xml.apache.org/xml-soap" xmlns:impl=" http://webservices.samples.jboss.org http://webservices.samples.jboss.org" xmlns:intf=" http://webservices.samples.jboss.org http://webservices.samples.jboss.org" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap=" http://schemas.xmlsoap.org/wsdl/soap/ http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema 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 http://webservices.samples.jboss.org" xmlns=" http://www.w3.org/2001/XMLSchema 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 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 http://localhost:8080/web_service/services/HelloWorld"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>
//==============================================================================

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/549550#549550]

Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100624/7dfdaa57/attachment-0001.html 


More information about the jboss-user mailing list