10 Replies Latest reply on Feb 8, 2006 2:30 PM by Rodney Kite

    Complex types in WS4EE.

    Kunarak Osatapirat Newbie

      i create a web service which pass and return parameters in complex type. i use wscompile to generate wsdl and jaxrpc-mapping file. it's look well i can deploy with no error. But i can't invoke my web service by DII client in EJB. Am i miss something. i'll explain how i create a service.

      this is SEI

      package com.vendora.search;
      import java.rmi.Remote;
      import java.rmi.RemoteException;
      
      import tu.cs.ips.search.ProductList;
      import tu.cs.ips.search.SearchInfo;
      
      public interface SearchEndpoint extends Remote {
       public ProductList searchProduct(SearchInfo si)throws RemoteException;
      }


      class ProductList is look like this.
      package tu.cs.ips.search;
      
      import java.io.Serializable;
      
      
      public class ProductList implements Serializable {
      
       Product[] List ;
       String VendorName ;
       ......{accessor,mutator and other methods}....
      



      class SearchInfo is look like this. (class Product is similar to this class)
      package tu.cs.ips.search;
      
      import java.io.Serializable;
      
      public class SearchInfo implements Serializable {
       private String Name[] ;
       private String Value[][] ;
       ......{accessor,mutator and other methods}....
      


      after i create all neccessary class
      first i run wscompile
      D:\test>wscompile -define -mapping build/jaxrpc-mapping.xml -d build -nd build -
      cp . -f:documentliteral config.xml


      this is config.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration
      xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
      <service
      name="SearchService"
      targetNamespace="http://tu.cs.ips/search"
      typeNamespace="http://tu.cs.ips/search/types"
      packageName="tu.cs.ips.search">
      <interface name="com.vendora.search.SearchEndpoint"/>
      </service>
      </configuration>


      generated wsdl and jaxrpc-mapping are
      <?xml version="1.0" encoding="UTF-8"?>
      
      <definitions name="SearchService" targetNamespace="http://tu.cs.ips/search" xmlns:tns="http://tu.cs.ips/search" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://tu.cs.ips/search/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
       <types>
       <schema targetNamespace="http://tu.cs.ips/search/types" xmlns:tns="http://tu.cs.ips/search/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://tu.cs.ips/search/types/arrays/java/lang" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
       <import namespace="http://tu.cs.ips/search/types/arrays/java/lang"/>
       <complexType name="searchProduct">
       <sequence>
       <element name="SearchInfo_1" type="tns:SearchInfo" nillable="true"/></sequence></complexType>
       <complexType name="SearchInfo">
       <sequence>
       <element name="name" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
       <element name="value" type="ns2:StringArray" minOccurs="0" maxOccurs="unbounded"/></sequence></complexType>
       <complexType name="searchProductResponse">
       <sequence>
       <element name="result" type="tns:ProductList" nillable="true"/></sequence></complexType>
       <complexType name="ProductList">
       <sequence>
       <element name="list" type="tns:Product" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
       <element name="vendorName" type="string" nillable="true"/></sequence></complexType>
       <complexType name="Product">
       <sequence>
       <element name="name" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
       <element name="value" type="ns2:StringArray" minOccurs="0" maxOccurs="unbounded"/></sequence></complexType>
       <element name="searchProduct" type="tns:searchProduct"/>
       <element name="searchProductResponse" type="tns:searchProductResponse"/></schema>
       <schema targetNamespace="http://tu.cs.ips/search/types/arrays/java/lang" xmlns:tns="http://tu.cs.ips/search/types/arrays/java/lang" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
       <import namespace="http://tu.cs.ips/search/types"/>
       <complexType name="StringArray">
       <sequence>
       <element name="value" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/></sequence></complexType></schema></types>
       <message name="SearchEndpoint_searchProduct">
       <part name="parameters" element="ns2:searchProduct"/></message>
       <message name="SearchEndpoint_searchProductResponse">
       <part name="result" element="ns2:searchProductResponse"/></message>
       <portType name="SearchEndpoint">
       <operation name="searchProduct">
       <input message="tns:SearchEndpoint_searchProduct"/>
       <output message="tns:SearchEndpoint_searchProductResponse"/></operation></portType>
       <binding name="SearchEndpointBinding" type="tns:SearchEndpoint">
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
       <operation name="searchProduct">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal"/></input>
       <output>
       <soap:body use="literal"/></output></operation></binding>
       <service name="SearchService">
       <port name="SearchEndpointPort" binding="tns:SearchEndpointBinding">
       <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>


      jaxrpc-mapping file
      <?xml version="1.0" encoding="UTF-8"?>
      <java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee" version="1.1" 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>tu.cs.ips.search</package-type>
      <namespaceURI>http://tu.cs.ips/search/types</namespaceURI>
      </package-mapping>
      <package-mapping>
      <package-type>tu.cs.ips.search</package-type>
      <namespaceURI>http://tu.cs.ips/search</namespaceURI>
      </package-mapping>
      <package-mapping>
      <package-type>tu.cs.ips.search._arrays.java.lang</package-type>
      <namespaceURI>http://tu.cs.ips/search/types/arrays/java/lang</namespaceURI>
      </package-mapping>
      <java-xml-type-mapping>
      <java-type>tu.cs.ips.search.ProductList</java-type>
      <root-type-qname xmlns:typeNS="http://tu.cs.ips/search/types">typeNS:ProductList</root-type-qname>
      <qname-scope>complexType</qname-scope>
      <variable-mapping>
      <java-variable-name>list</java-variable-name>
      <xml-element-name>list</xml-element-name>
      </variable-mapping>
      <variable-mapping>
      <java-variable-name>vendorName</java-variable-name>
      <xml-element-name>vendorName</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <java-xml-type-mapping>
      <java-type>com.vendora.search.SearchEndpoint_searchProduct_ResponseStruct</java-type>
      <root-type-qname xmlns:typeNS="http://tu.cs.ips/search/types">typeNS:searchProductResponse</root-type-qname>
      <qname-scope>complexType</qname-scope>
      <variable-mapping>
      <java-variable-name>result</java-variable-name>
      <xml-element-name>result</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <java-xml-type-mapping>
      <java-type>tu.cs.ips.search.Product</java-type>
      <root-type-qname xmlns:typeNS="http://tu.cs.ips/search/types">typeNS:Product</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>
      <variable-mapping>
      <java-variable-name>value</java-variable-name>
      <xml-element-name>value</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <java-xml-type-mapping>
      <java-type>com.vendora.search.SearchEndpoint_searchProduct_RequestStruct</java-type>
      <root-type-qname xmlns:typeNS="http://tu.cs.ips/search/types">typeNS:searchProduct</root-type-qname>
      <qname-scope>complexType</qname-scope>
      <variable-mapping>
      <java-variable-name>SearchInfo_1</java-variable-name>
      <xml-element-name>SearchInfo_1</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <java-xml-type-mapping>
      <java-type>tu.cs.ips.search.SearchInfo</java-type>
      <root-type-qname xmlns:typeNS="http://tu.cs.ips/search/types">typeNS:SearchInfo</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>
      <variable-mapping>
      <java-variable-name>value</java-variable-name>
      <xml-element-name>value</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <service-interface-mapping>
      <service-interface>tu.cs.ips.search.SearchService</service-interface>
      <wsdl-service-name xmlns:serviceNS="http://tu.cs.ips/search">serviceNS:SearchService</wsdl-service-name>
      <port-mapping>
      <port-name>SearchEndpointPort</port-name>
      <java-port-name>SearchEndpointPort</java-port-name>
      </port-mapping>
      </service-interface-mapping>
      <service-endpoint-interface-mapping>
      <service-endpoint-interface>com.vendora.search.SearchEndpoint</service-endpoint-interface>
      <wsdl-port-type xmlns:portTypeNS="http://tu.cs.ips/search">portTypeNS:SearchEndpoint</wsdl-port-type>
      <wsdl-binding xmlns:bindingNS="http://tu.cs.ips/search">bindingNS:SearchEndpointBinding</wsdl-binding>
      <service-endpoint-method-mapping>
      <java-method-name>searchProduct</java-method-name>
      <wsdl-operation>searchProduct</wsdl-operation>
      <wrapped-element/>
      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>tu.cs.ips.search.SearchInfo</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="http://tu.cs.ips/search">wsdlMsgNS:SearchEndpoint_searchProduct</wsdl-message>
      <wsdl-message-part-name>SearchInfo_1</wsdl-message-part-name>
      <parameter-mode>IN</parameter-mode>
      </wsdl-message-mapping>
      </method-param-parts-mapping>
      <wsdl-return-value-mapping>
      <method-return-value>tu.cs.ips.search.ProductList</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://tu.cs.ips/search">wsdlMsgNS:SearchEndpoint_searchProductResponse</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>


      i write webservice.xml by hand
      <?xml version="1.0" encoding="UTF-8"?>

      <webservices xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:impl="http://org.jboss.webservice/complexbean"
      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>SearchService</webservice-description-name>
      <wsdl-file>WEB-INF/wsdl/SearchService.wsdl</wsdl-file>
      <jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
      <port-component>
      <port-component-name>Search</port-component-name>
      <wsdl-port>SearchEndpointPort</wsdl-port>
      <service-endpoint-interface>com.vendora.search.SearchEndpoint</service-endpoint-interface>
      <service-impl-bean>
      <servlet-link>SearchEndpoint</servlet-link>
      </service-impl-bean>
      </port-component>
      </webservice-description>
      </webservices>


      and ws4ee-deployment.xml
      <deployment
      xmlns='http://xml.apache.org/axis/wsdd/'
      xmlns:java='http://xml.apache.org/axis/wsdd/providers/java'
      xmlns:soap='http://schemas.xmlsoap.org/soap/encoding/'
      xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

      <typeMapping
      qname='ns2:searchProduct' xmlns:ns2='http://tu.cs.ips/search/types'
      type='java:tu.cs.ips.search.SearchInfo'
      serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
      deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
      encodingStyle=''>
      </typeMapping>

      <typeMapping
      qname='ns2:searchProductResponse' xmlns:ns2='http://tu.cs.ips/search/types'
      type='java:tu.cs.ips.search.ProductList'
      serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
      deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
      encodingStyle=''>
      </typeMapping>

      <typeMapping
      qname='ns2:Product' xmlns:ns2='http://tu.cs.ips/search'
      type='java:tu.cs.ips.search.Product'
      serializer='org.apache.axis.encoding.ser.BeanSerializerFactory'
      deserializer='org.apache.axis.encoding.ser.BeanDeserializerFactory'
      encodingStyle=''>
      </typeMapping>

      </deployment>


      and add servlet tag in web.xml
      <servlet>
      <servlet-name>SearchEndpoint</servlet-name>
      <servlet-class>com.vendora.search.SearchEndpointImpl</servlet-class>
      </servlet>

      <servlet-mapping>
      <servlet-name>SearchEndpoint</servlet-name>
      <url-pattern>/search/service</url-pattern>
      </servlet-mapping>



      an invoker class code like this
      ServiceFactory serviceFactory = ServiceFactory.newInstance();
       Service service = serviceFactory.createService(new URL("http://localhost:8080/vendora/search/service?wsdl"), new QName("http://tu.cs.ips/search", "SearchService"));
       Call call = (Call) service.createCall(new QName("http://tu.cs.ips/search", "SearchEndpointPort"), "searchProduct");
       ProductList retstr = (ProductList) call.invoke(new Object[]{new SearchInfo()});



      when i test i got exceptions
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
      faultSubcode:
      faultString: java.io.IOException: No serializer found for class tu.cs.ips.search.SearchInfo in registry org.apache.axis.encoding.TypeMappingImpl@97b7e5
      faultActor:
      faultNode:
      faultDetail:


      am i miss something???
      please help me to solve this problem.
      thank u very much for all answer.