Hi All, My project has multiple java classes to be exposed as web services. The operations on those java web services are using a common set of bean classes (as method arguments) and exception classes (in the throws class).
I'm trying to generate the binding and wsdl files for the multiple services using the Jibx2WSDL tool but it seems that this scenario is not completely supported. The generated binding only has one binding definition for each exception class in the target namespace of one of the web services. But there are seperate wsdl and xsd files generated for each web service and each of those xsd files defines an element for the exception class in the namespace of that particular service. (See exmaple below) Next I try to generate the Axis2 client stubs from the wsdl files using the wsdl2java tool from axis2 but it complains that it can't find the binding definition for the exception classes. Am I correct in saying that this scenario (i.e. multiple webservices sharing common exception classes) is not supported in jib2wsdl? Any suggestions on how to deal with this scenario? Thanks Anuj Example: -------- AdminWSImpl.java (input to jibx2wsdl) -------------------------------------- package com.myproject.admin; import com.myproject.beans.ProductFamilyBean; import com.myproject.beans.SessionInfoBean; import com.myproject.exception.AuthorizationException; import com.myproject.exception.CachingException; import com.myproject.exception.InvalidInputDataException; public class AdminWSImpl { public SessionInfoBean authenticate(String user, String password) throws InvalidInputDataException, AuthorizationException { SessionInfoBean sessionInfoBean = null; return sessionInfoBean; } public ProductFamilyBean[] getFamilies(SessionInfoBean sessionBean) throws CachingException,AuthorizationException{ ProductFamilyBean[] productFamilyBeanArray = null; return productFamilyBeanArray; } } EngineWSImpl.java (input to jibx2wsdl) --------------------------------------- package com.myproject.engine; import com.myproject.beans.ProductBean; import com.myproject.beans.SessionInfoBean; import com.myproject.exception.AuthorizationException; import com.myproject.exception.CachingException; import com.myproject.exception.IllegalLocaleException; public class EngineWSImpl { public ProductBean[] getProducts(String productFamilyName, SessionInfoBean sessionBean) throws CachingException, AuthorizationException { ProductBean[] productBeanArray = null; return productBeanArray; } public void importCoreLegacyLocSource (String[] processLocales, SessionInfoBean sessionBean) throws IllegalLocaleException, AuthorizationException { } } All-binding-customizations.xml (input to jibx2wsdl) ---------------------------------------------- <custom force-classes="true"> <wsdl> <service class="com.myproject.admin.AdminWSImpl" service-name="AdminService"/> <service class="com.myproject.engine.EngineWSImpl" service-name="EngineService" /> </wsdl> </custom> Jibx2WSDL is invoked from ant using the command line args: <java classname="org.jibx.ws.wsdl.tools.Jibx2Wsdl" fork="true" classpathref="classpath" failonerror="true"> <arg value="-c"/> <arg value="${resources.dir}/jibx/All-binding-customizations.xml"/> <arg value="-p"/> <arg value="${classes.output.dir}"/> <arg value="-t"/> <arg value="${output.dir}/wsdl/generated"/> <arg value="com.myproject.engine.EngineWSImpl"/> <arg value="com.myproject.admin.AdminWSImpl"/> </java> Asuuming all the bean and exception classes are properly defined in the packages com.myproject.beans and com.myproject.exception respectively, the output that Jibx2WSDl produces contains one wsdl and xsd file each for AdminService and EngineService and one beans.xsd containig scheam definitions for the common beans classes. AdminService.wsdl (output from jibx2wsdl) ------------------------------------------ <wsdl:definitions xmlns:wsdl="..." xmlns:soap="..." xmlns:tns=" http://myproject.com/admin/AdminService" targetNamespace="http://myproject.com/admin/AdminService"> .... <xs:element name="caching"> <xs:complexType>....</xs:complexType> </xs:element> <xs:element name="invalidInputData"> <xs:complexType>....</xs:complexType> </xs:element> <xs:element name="authorization"> <xs:complexType>....</xs:complexType> </xs:element> .... <wsdl:message name="invalidInputDataFault"><wsdl:part name="fault" element="tns:invalidInputData"/></wsdl:message> <wsdl:message name="authorizationFault"><wsdl:part name="fault" element="tns:authorization"/></wsdl:message> <wsdl:message name="cachingFault"><wsdl:part name="fault" element="tns:caching"/></wsdl:message> .... </wsdl:definitions> AdminService.xsd (output from jibx2wsdl) ------------------------------------------ <xs:schema xmlns:xs="..." xmlns:tns="http://myproject.com/admin/AdminService" xmlns:ns1="http://myproject.com/beans" elementFormDefault="qualified" targetNamespace=" http://myproject.com/admin/AdminService"> .... <xs:element name="caching"> <xs:complexType>...</xs:complexType> </xs:element> <xs:element name="invalidInputData"> <xs:complexType>....</xs:complexType> </xs:element> <xs:element name="authorization"> <xs:complexType>....</xs:complexType> </xs:element> </xs:schema> admin_AdminServiceBinding.xml (output from jibx2wsdl) ----------------------------------------------------- <binding xmlns:tns="http://myproject.com/admin/AdminService" force-classes="true"> <namespace uri="http://myproject.com/admin/AdminService" default="elements"/> <mapping class="com.myproject.exception.InvalidInputDataExceptionData" name="invalidInputData"> ... </mapping> <mapping class="com.myproject.exception.AuthorizationExceptionData" name="authorization"> ... </mapping> <mapping class="com.myproject.exception.CachingExceptionData" name="caching"> ... </mapping> </binding> EngineService.wsdl (output from jibx2wsdl) ------------------------------------------ <wsdl:definitions xmlns:wsdl="..." xmlns:soap="..." xmlns:tns=" http://myproject.com/admin/AdminService" targetNamespace="http://myproject.com/admin/AdminService"> .... <xs:element name="caching"> <xs:complexType>....</xs:complexType> </xs:element> <xs:element name="invalidInputData"> <xs:complexType>....</xs:complexType> </xs:element> <xs:element name="authorization"> <xs:complexType>....</xs:complexType> </xs:element> .... <wsdl:message name="invalidInputDataFault"><wsdl:part name="fault" element="tns:invalidInputData"/></wsdl:message> <wsdl:message name="authorizationFault"><wsdl:part name="fault" element="tns:authorization"/></wsdl:message> <wsdl:message name="cachingFault"><wsdl:part name="fault" element="tns:caching"/></wsdl:message> .... </wsdl:definitions> EngineService.xsd (output from jibx2wsdl) ------------------------------------------ <xs:schema xmlns:xs="..." xmlns:tns=" http://myproject.com/engine/EngineService" xmlns:ns1=" http://myproject.com/beans" elementFormDefault="qualified" targetNamespace=" http://myproject.com/engine/EngineService"> .... <xs:element name="illegalLocale"> <xs:complexType>....</xs:complexType> </xs:element> </xs:schema> engine_EngineServiceBinding.xml (output from jibx2wsdl) ------------------------------------------------------- <binding xmlns:tns="http://myproject.com/engine/EngineService" force-classes="true"> <namespace uri="http://myproject.com/engine/EngineService" default="elements" prefix="tns"/> <mapping class="com.myproject.exception.IllegalLocaleExceptionData" name="illegalLocale"> .... </mapping> </binding> Next the Axis2 WSDL2Java command is run from ant (to produce the Axis2-Jibx wrapper classes i.e. AdminServiceMessageReceiverInOut.java and EngineServiceMessageReceiverInOut.java): <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="classpath"> <arg line="-o ${axis.output.dir}/${service.name}"/> <arg line="-uw -ss -sd"/> <arg line="-d jibx"/> <arg line="-Ebindingfile ${output.dir}/wsdl/generated/binding.xml"/> <arg line="-sn ${service.name}"/> <arg line="-uri ${output.dir}/wsdl/generated/${service.name}.wsdl"/> <arg line="-p ${service.impl.package}"/> </java> The above command is run twice once for AdminService.wsdl and then of EngineService.wsdl. It works fine for AdminService but for EngineService it generates the error: [java] Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: No mapping defined for element { http://myproject.com/engine/EngineService}authorization [java] at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271) [java] at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35) [java] at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24) [java] Caused by: java.lang.RuntimeException: No mapping defined for element {http://myproject.com/engine/EngineService}authorization [java] at org.apache.axis2.jibx.CodeGenerationUtility.mapQName(CodeGenerationUtility.java:1044) [java] at org.apache.axis2.jibx.CodeGenerationUtility.mapMessage(CodeGenerationUtility.java:1030) [java] at org.apache.axis2.jibx.CodeGenerationUtility.engage(CodeGenerationUtility.java:431) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.apache.axis2.wsdl.codegen.extension.JiBXExtension.engage(JiBXExtension.java:77) [java] at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224) [java] ... 2 more
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users