7 Replies Latest reply on Aug 16, 2007 4:01 PM by rknechtel

    beginner needs help

    vitor_b

      Hello

      Jboss: 4.0.5 GA

      You can skip following info and look directly on description and code.

      I'm rather new to WS. I decided to create my WebService using Stateless Session Bean, but i was getting errors. Thats why i decided to deply an example, and then modify it. Example is attached to book: JBoss 4.0 the Official Guide.

      The example service is quite simple. The operation accepts one argument: String, and returns String. I decided to change operation in order to make it accept Object. But I have failed, look at that:

      description and code

      Exception stack trace:

      12:46:56,093 ERROR [MainDeployer] Could not create deployment: file:/C:/Tutorial/jboss-4.0.5.GA/serer/default/deploy/hello-ejb.jar
      org.jboss.ws.WSException: Cannot obtain method parameter mapping for message part 'inputttttt' in wdl operation: hello at org.jboss.ws.deployment.JSR109MetaDataBuilder.buildParameterMetaDataRpc(JSR109MetaDataBulder.java:229)
      at org.jboss.ws.deployment.JSR109MetaDataBuilder.setupOperationsFromWSDL(JSR109MetaDataBuil
      er.java:196)
      at ...



      My session bean operation:

      public String hello(Input input)
       {
       return "Witaj " + input.getName() + "!";
       }


      Input object looks like that:

      package org.jboss.chap12.hello;
      
      public class Input {
      
       String name;
      
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
      }



      Wsdl file:


      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="HelloService"
       targetNamespace="http://hello.chap12.jboss.org/"
       xmlns:tns="http://hello.chap12.jboss.org/"
       xmlns="http://schemas.xmlsoap.org/wsdl/"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
       <types>
       <xsd:schema targetNamespace="http://hello.chap12.jboss.org/">
      
       <xsd:element name="input" type="tns:Input"/>
      
       <xsd:complexType name="Input">
       <xsd:sequence>
       <xsd:element name="name" type="xsd:string"/>
       </xsd:sequence>
       </xsd:complexType> </xsd:schema>
       </types>
       <message name="Hello_hello">
       <part name="inputttttt" type="tns:Input"/>
       </message> <message name="Hello_helloResponse">
       <part name="result" type="xsd:string"/>
       </message>
       <portType name="Hello">
       <operation name="hello" parameterOrder="inputttttt" >
       <input message="tns:Hello_hello"/>
       <output message="tns:Hello_helloResponse"/>
       </operation>
       </portType> <binding name="HelloBinding" type="tns:Hello">
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
       <operation name="hello">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://hello.chap12.jboss.org/"/>
       </input>
       <output>
       <soap:body use="literal" namespace="http://hello.chap12.jboss.org/"/>
       </output>
       </operation>
       </binding>
       <service name="HelloService">
       <port name="HelloPort" binding="tns:HelloBinding" >
       <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
       </port>
       </service>
      </definitions>
      


      Mapping file:

      <?xml version="1.0" encoding="UTF-8"?>
      <java-wsdl-mapping version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
      
      
       <java-xml-type-mapping>
       <java-type>org.jboss.chap12.hello.Input</java-type>
       <root-type-qname xmlns:typeNS='http://hello.chap12.jboss.org/'>typeNS:Input</root-type-qname>
       <qname-scope>complexType</qname-scope>
       <variable-mapping>
       <java-variable-name>name</java-variable-name>
       <xml-element-name>name</xml-element-name>
       </variable-mapping>
       </java-xml-type-mapping>
       <package-mapping>
       <package-type>org.jboss.chap12.hello</package-type>
       <namespaceURI>http://hello.chap12.jboss.org/types</namespaceURI>
       </package-mapping>
       <package-mapping>
       <package-type>org.jboss.chap12.hello</package-type>
       <namespaceURI>http://hello.chap12.jboss.org/</namespaceURI>
       </package-mapping>
       <service-interface-mapping>
       <service-interface>org.jboss.chap12.hello.HelloService</service-interface>
       <wsdl-service-name xmlns:serviceNS="http://hello.chap12.jboss.org/">serviceNS:HelloService</wsdl-service-name>
       <port-mapping>
       <port-name>HelloPort</port-name>
       <java-port-name>HelloPort</java-port-name>
       </port-mapping>
       </service-interface-mapping>
       <service-endpoint-interface-mapping>
       <service-endpoint-interface>org.jboss.chap12.hello.Hello</service-endpoint-interface>
       <wsdl-port-type xmlns:portTypeNS="http://hello.chap12.jboss.org/">portTypeNS:Hello</wsdl-port-type>
       <wsdl-binding xmlns:bindingNS="http://hello.chap12.jboss.org/">bindingNS:HelloBinding</wsdl-binding>
       <service-endpoint-method-mapping>
       <java-method-name>hello</java-method-name>
       <wsdl-operation>hello</wsdl-operation>
       <method-param-parts-mapping>
       <param-position>0</param-position>
       <param-type>org.jboss.chap12.hello.Input</param-type>
       <wsdl-message-mapping>
       <wsdl-message xmlns:wsdlMsgNS="http://hello.chap12.jboss.org/">wsdlMsgNS:Hello_hello</wsdl-message>
       <wsdl-message-part-name>inputttttt</wsdl-message-part-name>
       <parameter-mode>IN</parameter-mode>
       </wsdl-message-mapping>
       </method-param-parts-mapping>
       <wsdl-return-value-mapping>
       <method-return-value>java.lang.String</method-return-value>
       <wsdl-message xmlns:wsdlMsgNS="http://hello.chap12.jboss.org/">wsdlMsgNS:Hello_helloResponse</wsdl-message>
       <wsdl-message-part-name>result</wsdl-message-part-name>
       </wsdl-return-value-mapping>
       </service-endpoint-method-mapping>
       </service-endpoint-interface-mapping>
      </java-wsdl-mapping>
      



      For me looks like everything is fine, but it is not. The question is: why?
      Could you help me?

      Thank you in advance.

      vitor_b

        • 1. Re: beginner needs help
          nean

          i have the same problem than you, it's a problem of mapping, like the object isn't known or built...

          So if someone have the solution...

          thanks

          • 2. Re: beginner needs help
            monowai

            Assuming you're using jbossws 1.2

            Your Input class needs to expose it's properties with tags similar to:

            @XmlAccessorType(XmlAccessType.FIELD)
            @XmlType(name = "Input", propOrder = {
             "firstName",
             "lastName"})


            This will allow wsconsume & produce (and the JBoss deployer) to create the necessary complex types and map them to simple XML types

            To the best of my knowledge, you can not pass complex datatypes as parameters, but someone will probably prove me wrong! I haven't had a need to do it yet.

            Make sure you familiarise yourself with the examples at
            http://jbws.dyndns.org/mediawiki/index.php/Main_Page

            If you're mucking around maintaining WSDL files, you're making too much work for yourself.

            hth.

            • 3. Re: beginner needs help
              vitor_b

              Hello

              Thank you for your reply.

              I haven't tried your solution, since i created ant task, which generates mapping and wsdl files for me. With these files my web service (even with more complex input and output) works fine.
              And i didn't have to add these tags. Maybe that was becouse of my version of jbossws (1.4) but I'm really not sure. I only had to create wscompile-config.xml file.

              The problem described in my first post was occured becouse i created these files by my hand. I did it becouse i need to understand every aspect of creating these files.

              And the last thing: i've seen webservice with extremally complex input and output, but someone else created it.

              Best regards

              vitor_b

              • 4. Re: beginner needs help
                nean

                 

                "vitor_b" wrote:
                Hello

                Thank you for your reply.

                I haven't tried your solution, since i created ant task, which generates mapping and wsdl files for me. With these files my web service (even with more complex input and output) works fine.
                And i didn't have to add these tags. Maybe that was becouse of my version of jbossws (1.4) but I'm really not sure. I only had to create wscompile-config.xml file.

                The problem described in my first post was occured becouse i created these files by my hand. I did it becouse i need to understand every aspect of creating these files.

                And the last thing: i've seen webservice with extremally complex input and output, but someone else created it.

                Best regards

                vitor_b



                Could you explain exactly how you did it? all steps to obtain this please...

                Thanks

                nean

                • 5. Re: beginner needs help
                  vitor_b

                  Sorry for such a long time you had to wait for my reply.

                  First thing you need is: JWSDP (Java Web Services Developer Pack). You can download it from www.sun.com. I use jwsdp-1.4.

                  And here it is ant task which will generate for you jaxrpc-mapping and wsdl files:

                  First we need to set path to JWSDP:

                  <property name="jwsdp.dir" value="<your path>\jwsdp-1.4" />
                   <property name="classes.dir" value="<compiled classes>\bin" />


                  Replace values in <> to your specific ones.

                  Now we have to specify jar libraries we will use:

                  <path id="jwsdp.lib.path">
                   <fileset dir="${jwsdp.dir}/jwsdp-shared">
                   <include name="**/*.jar"/>
                   </fileset>
                  
                   <fileset dir="${jwsdp.dir}/jaxrpc">
                   <include name="**/*.jar"/>
                   </fileset>
                  
                   <fileset dir="${jwsdp.dir}/saaj">
                   <include name="**/*.jar"/>
                   </fileset>
                   </path>


                  We need one more library (we need class com.sun.tools.javac.Main):

                  <path id="wscompile.task.classpath">
                   <path refid="jwsdp.lib.path"/>
                   <fileset dir="${java.home}/../lib" includes="tools.jar"/>
                   </path>



                  Now we define our own ant task:

                  <taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile" classpathref="wscompile.task.classpath"/>


                  And we run it:

                  <target name="run-wscompile" depends="xdoclet-build">
                   <wscompile base="${res-generated-dir}"
                   fork="true"
                   server="true"
                   features="rpcliteral"
                   mapping="${res-gen-ws}/jaxrpc-mapping.xml"
                   config="${res-hand-made-dir}/wscompile-config.xml"
                   nonClassDir="${res-gen-ws}">
                  
                   <classpath>
                   <path refid="wscompile.task.classpath"/>
                   <pathelement location="${classes.dir}"/>
                   </classpath>
                  
                   </wscompile>
                   </target>


                  res-gen-ws and res-hand-made-dir are my dirs.
                  res-gen-ws is the directory which will contain generated jaxrpc-mapping and wsdl files. But wscompile task needs one more thing: wscompile-config.xml

                  This file contains info which will be used for generating files for you.
                  My file looks like that:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
                   <service name="NameWebService"
                   targetNamespace="http://localhost:8080/jmsprototype"
                   typeNamespace="http://localhost:8080/jmsprototype/types"
                   packageName="ws.bean">
                   <interface name="ws.bean.WebService"/>
                   </service>
                  </configuration>


                  packageName - package contains web service classes
                  Element interface contains WebService class, that implements interface java.rmi.Remote.

                  service name - name for service in wsdl file
                  <service name="NameWebService">


                  You still have to create webservices.xml file yourself. But that is not a very hard thing to do.

                  If you have any questions just ask.
                  I will check this topic later.

                  Take care

                  vitor_b






                  • 6. Re: beginner needs help
                    rknechtel

                    I have used wscompile from command line under Linux but I just can't seem to get it to work under Winblows. So I decided to try and do it via the ant task. But Eclipse/ant complain with the all to persistant "taskdef class com.sun.xml.rpc.tools.ant.Wscompile cannot be found" error. I have a directory called jwsdplibs that I put all the jars from the jaxrpc, jwsdp-shared, saaj directories into. I'm using JWSDP 1.6 and I tried jwsdp 2.0, I'm using jdk1.5.0_11.


                    Below is my build.xml code.

                    
                    My ant.properties has this:
                    jwsdp.home=/opt/jwsdplibs
                    -------
                    
                    build.xml
                    ----------------
                    
                    <property name="jwsdp.dir" value="${jwsdp.home}" />
                     <!-- =================================================================== -->
                     <!-- wscompile Task -->
                     <!-- =================================================================== -->
                     <path id="wscompile.classpath">
                     <fileset dir="${jwsdp.dir}">
                     <include name="**/*.jar"/>
                     </fileset>
                     <fileset dir="${java.home}">
                     <include name="**/*.jar" />
                     </fileset>
                     <fileset dir="${classes.dir}">
                     <include name="**/*.class" />
                     </fileset>
                     </path>
                    
                    <taskdef name="wscompile" classpath="${wscompile.classpath}" classname="com.sun.xml.rpc.tools.ant.Wscompile" />
                     <target name="generate">
                     <wscompile
                     fork="true"
                     verbose="true"
                     wsdlFile="claimstatus2.wsdl"
                     classpath="${classpath}"
                     server="true"
                     features="documentliteral"
                     sourceBase="${src.dir}"
                     mapping=""
                     config="${wscompileconfig}">
                     </wscompile>
                     </target>
                    


                    I can't understand why it can't find the class.
                    Here are the jars in my jwsdplibs directory:
                    dom.jar
                    sax.jar
                    xalan.jar
                    xercesImpl.jar
                    activation.jar
                    commons-beanutils.jar
                    commons-collections.jar
                    commons-digester.jar
                    commons-logging.jar
                    jaas.jar
                    jax-qname.jar
                    jaxp-api.jar
                    jaxrpc-api.jar
                    jaxrpc-impl.jar
                    jaxrpc-spi.jar
                    jta-spec1_0_1.jar
                    mail.jar
                    namespace.jar
                    relaxngDatatype.jar
                    saaj-api.jar
                    saaj-impl.jar
                    xmlsec.jar
                    xsdlib.jar

                    Does anyone have any idea what is going on? Have you had similar issues where it can't find the wscompile ant class?

                    Thanks,


                    • 7. Re: beginner needs help
                      rknechtel

                      I figured it out.

                      I changed:

                      <taskdef name="wscompile" classpath="${wscompile.classpath}" classname="com.sun.xml.rpc.tools.ant.Wscompile" />
                      


                      To:
                       <taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile">
                       <classpath>
                       <fileset dir="${wscompile.classpath}">
                       <include name='**/*.jar'/>
                       </fileset>
                       </classpath>
                       </taskdef>
                      


                      That seemed to take care of the problem.