13 Replies Latest reply on Dec 14, 2005 8:31 PM by jason.greene

    Problem with typeMapping when turning an EJB into a WebServi

    nycos62

      *** The Endpoint Interface :

      package helloworld.ejb;

      import java.rmi.Remote;
      import java.rmi.RemoteException;


      public interface HelloWorldEndpoint extends Remote {

      public String getHello(String nom) throws RemoteException;

      }

      *** the wsdl file :

      <?xml version="1.0" encoding="UTF-8"?>

      <definitions
      name="HelloWorldService"
      targetNamespace="urn:HelloWorldService"
      xmlns:tns="urn:HelloWorldService"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">


      <xsd:schema targetNamespace="urn:HelloWorldService">
      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
      </xsd:schema>










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

      <soap:operation soapAction=""/>

      <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:HelloWorldService"/>

      <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:HelloWorldService"/>


      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>

      *** the jaxrpc-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">

      <package-mapping>
      <package-type>helloworld.ejb</package-type>
      urn:HelloWorldService
      </package-mapping>

      <service-interface-mapping>
      <service-interface>helloworld.ejb.HelloWorldService</service-interface>
      <wsdl-service-name xmlns:serviceNS="urn:HelloWorldService">serviceNS:HelloWorldService</wsdl-service-name>
      <port-mapping>
      <port-name>HelloWorldEndpointPort</port-name>
      <java-port-name>HelloWorldEndpointPort</java-port-name>
      </port-mapping>
      </service-interface-mapping>

      <service-endpoint-interface-mapping>
      <service-endpoint-interface>helloworld.ejb.HelloWorldEndpoint</service-endpoint-interface>
      <wsdl-port-type xmlns:portTypeNS="urn:HelloWorldService">portTypeNS:HelloWorldEndpoint</wsdl-port-type>
      <wsdl-binding xmlns:bindingNS="urn:HelloWorldService">bindingNS:HelloWorldEndpointBinding</wsdl-binding>

      <service-endpoint-method-mapping>
      <java-method-name>getHello</java-method-name>
      <wsdl-operation>getHello</wsdl-operation>

      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>java.lang.String</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="urn:HelloWorldService">wsdlMsgNS:HelloWorldEndpoint_getHello</wsdl-message>
      <wsdl-message-part-name>String_1</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="urn:HelloWorldService">wsdlMsgNS:HelloWorldEndpoint_getHelloResponse</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>

      *** the webservices.xml file

      <?xml version='1.0' encoding='UTF-8' ?>
      <webservices
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:impl="http://com.myapp/ws4ee"
      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_web_services_1_1.xsd"
      version="1.1">

      <webservice-description>
      <webservice-description-name>HelloWorldService</webservice-description-name>
      <wsdl-file>META-INF/wsdl/HelloWorldService.wsdl</wsdl-file>
      <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
      <port-component>
      port component description
      <port-component-name>HelloWorldService</port-component-name>
      <wsdl-port>HelloWorldEndpointPort</wsdl-port>
      <service-endpoint-interface>helloworld.ejb.HelloWorldEndpoint</service-endpoint-interface>
      <service-impl-bean>
      <ejb-link>helloworld</ejb-link>
      </service-impl-bean>
      </port-component>
      </webservice-description>


      *** the EJB-jar.xml file

      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>

      <enterprise-beans>

      <display-name>helloworld</display-name>
      <ejb-name>helloworld</ejb-name>
      <service-endpoint>helloworld.ejb.HelloWorldEndpoint</service-endpoint>
      helloworld.ejb.HelloWorldHome
      helloworld.ejb.HelloWorld
      <local-home>helloworld.ejb.HelloWorldLocalHome</local-home>
      helloworld.ejb.HelloWorldLocal
      <ejb-class>helloworld.ejb.HelloWorldBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>

      </ejb-jar>

        • 1. Re: Problem with typeMapping when turning an EJB into a WebS
          nycos62

          *** the Endpoint Interface ***

          package helloworld.ejb;
          
          import java.rmi.Remote;
          import java.rmi.RemoteException;
          
          public interface HelloWorldEndpoint extends Remote {
          
           public String getHello(String nom) throws RemoteException;
          
          }


          *** the wsdl file ***
          <?xml version="1.0" encoding="UTF-8"?>
          
          <definitions
           name="HelloWorldService"
           targetNamespace="urn:HelloWorldService"
           xmlns:tns="urn:HelloWorldService"
           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="urn:HelloWorldService">
           <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
           <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
           </xsd:schema>
           </types>
           <message name="HelloWorldEndpoint_getHello">
           <part name="String_1" type="xsd:string"/></message>
           <message name="HelloWorldEndpoint_getHelloResponse">
           <part name="result" type="xsd:string"/></message>
           <portType name="HelloWorldEndpoint">
           <operation name="getHello" parameterOrder="String_1">
           <input message="tns:HelloWorldEndpoint_getHello"/>
           <output message="tns:HelloWorldEndpoint_getHelloResponse"/></operation></portType>
           <binding name="HelloWorldEndpointBinding" type="tns:HelloWorldEndpoint">
           <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
           <operation name="getHello">
           <soap:operation soapAction=""/>
           <input>
           <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:HelloWorldService"/></input>
           <output>
           <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:HelloWorldService"/></output></operation></binding>
           <service name="HelloWorldService">
           <port name="HelloWorldEndpointPort" binding="tns:HelloWorldEndpointBinding">
           <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>
          


          *** the jaxprc-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">
          
           <package-mapping>
           <package-type>helloworld.ejb</package-type>
           <namespaceURI>urn:HelloWorldService</namespaceURI>
           </package-mapping>
          
           <service-interface-mapping>
           <service-interface>helloworld.ejb.HelloWorldService</service-interface>
           <wsdl-service-name xmlns:serviceNS="urn:HelloWorldService">serviceNS:HelloWorldService</wsdl-service-name>
           <port-mapping>
           <port-name>HelloWorldEndpointPort</port-name>
           <java-port-name>HelloWorldEndpointPort</java-port-name>
           </port-mapping>
           </service-interface-mapping>
          
           <service-endpoint-interface-mapping>
           <service-endpoint-interface>helloworld.ejb.HelloWorldEndpoint</service-endpoint-interface>
           <wsdl-port-type xmlns:portTypeNS="urn:HelloWorldService">portTypeNS:HelloWorldEndpoint</wsdl-port-type>
           <wsdl-binding xmlns:bindingNS="urn:HelloWorldService">bindingNS:HelloWorldEndpointBinding</wsdl-binding>
          
           <service-endpoint-method-mapping>
           <java-method-name>getHello</java-method-name>
           <wsdl-operation>getHello</wsdl-operation>
          
           <method-param-parts-mapping>
           <param-position>0</param-position>
           <param-type>java.lang.String</param-type>
           <wsdl-message-mapping>
           <wsdl-message xmlns:wsdlMsgNS="urn:HelloWorldService">wsdlMsgNS:HelloWorldEndpoint_getHello</wsdl-message>
           <wsdl-message-part-name>String_1</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="urn:HelloWorldService">wsdlMsgNS:HelloWorldEndpoint_getHelloResponse</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>
          
          

          *** the webservices.xml ***
          <?xml version='1.0' encoding='UTF-8' ?>
          <webservices
           xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:impl="http://com.myapp/ws4ee"
           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_web_services_1_1.xsd"
           version="1.1">
          
           <webservice-description>
           <webservice-description-name>HelloWorldService</webservice-description-name>
           <wsdl-file>META-INF/wsdl/HelloWorldService.wsdl</wsdl-file>
           <jaxrpc-mapping-file>META-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
           <port-component>
           <description>port component description</description>
           <port-component-name>HelloWorldService</port-component-name>
           <wsdl-port>HelloWorldEndpointPort</wsdl-port>
           <service-endpoint-interface>helloworld.ejb.HelloWorldEndpoint</service-endpoint-interface>
           <service-impl-bean>
           <ejb-link>helloworld</ejb-link>
           </service-impl-bean>
           </port-component>
           </webservice-description>
          </webservices>
          


          • 2. Re: Problem with typeMapping when turning an EJB into a WebS
            nycos62

            when i use the client class :

            public static void main(String[] args) throws MalformedURLException, ServiceException, RemoteException {
            
            String urlstr="http://localhost:9001/mywebservices/HelloWorldService?wsdl";
            System.out.println("Contacting webservice at " + urlstr);
            URL url = new URL(urlstr);
            QName qname = new QName("urn:HelloWorldService","HelloWorldService");
            
            ServiceFactory factory = ServiceFactory.newInstance();
            Service service = factory.createService(url, qname);
            
            HelloWorld hello = (HelloWorld) service.getPort(HelloWorld.class);
            System.out.println("Service found");
            System.out.println("hello.getHello(truc)");
            System.out.println(hello.getHello("truc")); <=== return an error
            


            ** error stack **


            java.lang.NullPointerException
            at org.apache.axis.client.Call.getTypeMapping(Call.java:2402)
            at org.apache.axis.client.Call.setReturnType(Call.java:1230)
            at org.apache.axis.client.Call.setOperation(Call.java:1412)
            at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:369)
            at $Proxy0.getHello(Unknown Source)
            at utils.locator.WSLocator.main(WSLocator.java:64)
            Exception in thread "main"


            • 3. Re: Problem with typeMapping when turning an EJB into a WebS
              nycos62

              perhaps it s depend of the SOAP version because i read somewhere that Soap 1.1 can only process atomic variable like char and not string.
              May I perhaps make a new type string (an array of char) ?
              or specify that i want using SOAP 1.2 but i don't know how.

              • 4. Re: Problem with typeMapping when turning an EJB into a WebS
                nycos62

                (i m using JbossWS, jaxrpc, wscompile, Jboss 4.0.1 sp1)

                • 5. Re: Problem with typeMapping when turning an EJB into a WebS
                  thomas.diesler

                  An NPE is not acceptable. I assigned this JIRA issue
                  http://jira.jboss.com/jira/browse/JBWS-203

                  Your WS uses rpc/encoded which is not allowed by the BasicProfile-1.0. Try using rpc/literal.

                  Have you seen the StepByStep tutorials in the wiki?

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

                  • 6. Re: Problem with typeMapping when turning an EJB into a WebS
                    nycos62

                    i ve read the wiki another time and i've generated rpc/literal files with wscompile but the customer class still send back me a NPE on Call.GetTypeMapping.

                    • 7. Re: Problem with typeMapping when turning an EJB into a WebS
                      nycos62

                      I hope that one day JBoss will be able to compete with Dotnet about webservices.

                      • 8. Re: Problem with typeMapping when turning an EJB into a WebS
                        debanjan

                        Well this issue is a absolute SHOW STOPPER.

                        I need to run webservices on my JBoss 4.0.1sp1 installation. I am using wscompile from sun jwsdp-1.5. I am trying to run a simple web service (no EJB). Everything is deployed fine - but the client throws this error always and thus I am stuck. NPE with getTypeMapping. The module is axis-ws4ee.


                        Can anyone tell me is there is a way around to make my services run?. Or when this issue will be resolved ? Can I replace the axis-ws4ee file with a version which doesnot have this problem - even back versions ? If so - where to get the file..

                        Thanks in advance

                        • 9. Re: Problem with typeMapping when turning an EJB into a WebS
                          debanjan

                          Incidently I tried with both String and int. Same problem - so looks like, it is not an issue with the "String" data type.

                          • 10. Re: Problem with typeMapping when turning an EJB into a WebS
                            maherhome

                            I currently see this error when I run Java 1.5, but not Java 1.4. So if you're runing 1.5, try 1.4.

                            I had problems in another project with 1.4->1.5 and axis.jar. I solved it by getting a 1.5 axis.jar.

                            But now I'm looking for a 1.5 version of this JBoss fork(?) of axis.jar (axis-ws4ee.jar) and haven't had any luck.

                            Steve

                            • 11. Re: Problem with typeMapping when turning an EJB into a WebS
                              thomas.diesler

                              The issue target release tells you the expected fix date. You can also become a jboss customer if you business is such that you cannot rely on free support (i.e. you need a patch in a timely manner)

                              • 12. Re: Problem with typeMapping when turning an EJB into a WebS
                                adrianp1

                                I've run into this problem myself and traced it the absence of a client-config.wsdd file on the classpath of the invoking client code (running from an EAR deployed under JBoss) - the Axis engine was picking up the default client-config.wsdd supplied by JBoss which contained references to classes which were not available to my client code. The net result was that the ClassNotFoundException thrown during initialization resulted in a TypeMappingRegistry in the main engine configuration. Or something like that.

                                The moral is: make sure you have a usable client-config.wsdd on your client's classpath.

                                • 13. Re: Problem with typeMapping when turning an EJB into a WebS
                                  jason.greene

                                  If you followed

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

                                  Can you post your wsdl, jaxrpc-mapping, SEI. We can look into this further then.

                                  -Jason