In short: wsdl2java produces duplicate copies of my JavaBean classes, but using a generated (different) package name.

Hi,

In an effort to learn web services + axis, I wrote a simple standalong java-client - to - web service app. The idea is that Client uses JavaBean classes to display some info and do some work, it also uses those beans as input args to the Web Service; and Service uses those same JavaBeans as return params. The package structure of my app is as follows:

computeservice.beans - contains two JavaBean classes (InputValue, and OutputValue) used throughout client and server classes to do internal work, also used as args/return types with web service.

computeservice.service.ComputeService - server side class. Methods of these classes are exposed as web service operations (using WSDL file)

computeservice.client.ServiceClientApp - client side standalone app, accumulates user input into InputValue, passes InputValue as arg to web service operation, gets OutputValue in return, displays that locally.

I'd like to distribute this app in two packages: .WAR file for server-side deployment, and a .JAR for desktop java client app. It is my understanding that I should package computeservice.beans into both archives, since both .client and .service classes use them.

Here's the problem:

On the server side, SEI defines operation:

public computeservice.beans.OutputValue doMultiply(computeservice.beans.InputValue inputValue)

When I use wsdl2java to generate client-side classes necessary to talk to the service, InputValue and OutputValue are also generated (even though I already have them computeservice.beans). But their package names are incorrect:

"package ComputeServiceWS;
public class InputValue implements java.io.Serializable {...." (similarly OutputValue)

public ComputeServiceWS.OutputValue doMultiply(ComputeServiceWS.InputValue inputValue_1) throws java.rmi.RemoteException;

This  precludes the following from working in my standalone app:

computeservice.beans.InputValue inputFromUserGUI =  gui.getInput();
computeservice.beans.OutputValue retValue = service.doMultiply(inputFromUserGUI); //this won't work, as service expects ComputeServiceWS.InputValue,
not computeservice.beans.InputValue, and I can't just cast one to another.

gui.displayOutput(retValue);

//declaration
public void displayOutput(computeservice.beans.OutputValue)

Here are my questions:
-How did wsdl2java decide on package name "ComputeServiceWS" for InputValue/OutputValue instead of computeservice.beans? -Since I already have source code for InputValue and OutputValue included with client, any chance of precluding wsdl2java from generating these classes (avoid code duplication)? -If generation of InputValue and OutputValue source is inevitable, can I force wsdl2java to produce correct package names. Or is that a setting in WSDL file itself?

Ant task used to produce stubs:
   <!-- generate WS stubs -->
   <target name="gen-ws-client">
       <axis-wsdl2java
           output="scratch"
           testcase="true"
           verbose="true"
           url="http://localhost:8081/ComputeWeb/ComputeServiceWS?WSDL"; >
       </axis-wsdl2java>
   </target>

I'm attaching some relevant files.

thanks a lot,
-nikita


<?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>computeservice.service</package-type>
<namespaceURI>urn:ComputeServiceWS/types</namespaceURI>
</package-mapping>
<package-mapping>
<package-type>computeservice.service</package-type>
<namespaceURI>urn:ComputeServiceWS/wsdl</namespaceURI>
</package-mapping>
<java-xml-type-mapping>
<java-type>computeservice.service.ComputeServiceWSSEI_doMultiply_ResponseStruct</java-type>
<root-type-qname xmlns:typeNS="urn:ComputeServiceWS/types">typeNS:doMultiplyResponse</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>computeservice.beans.OutputValue</java-type>
<root-type-qname xmlns:typeNS="urn:ComputeServiceWS/types">typeNS:OutputValue</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>computeservice.beans.InputValue</java-type>
<root-type-qname xmlns:typeNS="urn:ComputeServiceWS/types">typeNS:InputValue</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>computeservice.service.ComputeServiceWSSEI_doMultiply_RequestStruct</java-type>
<root-type-qname xmlns:typeNS="urn:ComputeServiceWS/types">typeNS:doMultiply</root-type-qname>
<qname-scope>complexType</qname-scope>
<variable-mapping>
<java-variable-name>InputValue_1</java-variable-name>
<xml-element-name>InputValue_1</xml-element-name>
</variable-mapping>
</java-xml-type-mapping>
<service-interface-mapping>
<service-interface>computeservice.service.ComputeServiceWS</service-interface>
<wsdl-service-name xmlns:serviceNS="urn:ComputeServiceWS/wsdl">serviceNS:ComputeServiceWS</wsdl-service-name>
<port-mapping>
<port-name>ComputeServiceWSSEIPort</port-name>
<java-port-name>ComputeServiceWSSEIPort</java-port-name>
</port-mapping>
</service-interface-mapping>
<service-endpoint-interface-mapping>
<service-endpoint-interface>computeservice.service.ComputeServiceWSSEI</service-endpoint-interface>
<wsdl-port-type xmlns:portTypeNS="urn:ComputeServiceWS/wsdl">portTypeNS:ComputeServiceWSSEI</wsdl-port-type>
<wsdl-binding xmlns:bindingNS="urn:ComputeServiceWS/wsdl">bindingNS:ComputeServiceWSSEIBinding</wsdl-binding>
<service-endpoint-method-mapping>
<java-method-name>doMultiply</java-method-name>
<wsdl-operation>doMultiply</wsdl-operation>
<wrapped-element/>
<method-param-parts-mapping>
<param-position>0</param-position>
<param-type>computeservice.beans.InputValue</param-type>
<wsdl-message-mapping>
<wsdl-message xmlns:wsdlMsgNS="urn:ComputeServiceWS/wsdl">wsdlMsgNS:ComputeServiceWSSEI_doMultiply</wsdl-message>
<wsdl-message-part-name>InputValue_1</wsdl-message-part-name>
<parameter-mode>IN</parameter-mode>
</wsdl-message-mapping>
</method-param-parts-mapping>
<wsdl-return-value-mapping>
<method-return-value>computeservice.beans.OutputValue</method-return-value>
<wsdl-message xmlns:wsdlMsgNS="urn:ComputeServiceWS/wsdl">wsdlMsgNS:ComputeServiceWSSEI_doMultiplyResponse</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>
<?xml version='1.0' encoding='UTF-8' ?>
<webservices 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_web_services_1_1.xsd' version='1.1'>
	<webservice-description>
		<webservice-description-name>ComputeServiceWS</webservice-description-name>
		<wsdl-file>WEB-INF/wsdl/ComputeServiceWS.wsdl</wsdl-file>
		<jaxrpc-mapping-file>WEB-INF/ComputeServiceWS-mapping.xml</jaxrpc-mapping-file>
		<port-component xmlns:wsdl-port_ns='urn:ComputeServiceWS/wsdl'>
			<port-component-name>ComputeServiceWS</port-component-name>
			<wsdl-port>wsdl-port_ns:ComputeServiceWSSEIPort</wsdl-port>
			<service-endpoint-interface>computeservice.service.ComputeServiceWSSEI</service-endpoint-interface>
			<service-impl-bean>
				<servlet-link>WSServlet_ComputeServiceWS</servlet-link>
			</service-impl-bean>
		</port-component>
	</webservice-description>
</webservices>
<?xml version="1.0" encoding="UTF-8"?>

<definitions name="ComputeServiceWS" targetNamespace="urn:ComputeServiceWS/wsdl" xmlns:tns="urn:ComputeServiceWS/wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns2="urn:ComputeServiceWS/types" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";>
  <types>
    <schema targetNamespace="urn:ComputeServiceWS/types" xmlns:tns="urn:ComputeServiceWS/types" 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";>
      <complexType name="doMultiply">
        <sequence>
          <element name="InputValue_1" type="tns:InputValue" nillable="true"/></sequence></complexType>
      <complexType name="InputValue">
        <sequence>
          <element name="name" type="string" nillable="true"/>
          <element name="value" type="int"/></sequence></complexType>
      <complexType name="doMultiplyResponse">
        <sequence>
          <element name="result" type="tns:OutputValue" nillable="true"/></sequence></complexType>
      <complexType name="OutputValue">
        <sequence>
          <element name="name" type="string" nillable="true"/>
          <element name="value" type="int"/></sequence></complexType>
      <element name="doMultiply" type="tns:doMultiply"/>
      <element name="doMultiplyResponse" type="tns:doMultiplyResponse"/></schema></types>
  <message name="ComputeServiceWSSEI_doMultiply">
    <part name="parameters" element="ns2:doMultiply"/></message>
  <message name="ComputeServiceWSSEI_doMultiplyResponse">
    <part name="result" element="ns2:doMultiplyResponse"/></message>
  <portType name="ComputeServiceWSSEI">
    <operation name="doMultiply">
      <input message="tns:ComputeServiceWSSEI_doMultiply"/>
      <output message="tns:ComputeServiceWSSEI_doMultiplyResponse"/></operation></portType>
  <binding name="ComputeServiceWSSEIBinding" type="tns:ComputeServiceWSSEI">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; style="document"/>
    <operation name="doMultiply">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/></input>
      <output>
        <soap:body use="literal"/></output></operation></binding>
  <service name="ComputeServiceWS">
    <port name="ComputeServiceWSSEIPort" binding="tns:ComputeServiceWSSEIBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>
<?xml version='1.0' encoding='UTF-8' ?>
<configuration xmlns='http://java.sun.com/xml/ns/jax-rpc/ri/config'>
	<service name='ComputeServiceWS' targetNamespace='urn:ComputeServiceWS/wsdl' typeNamespace='urn:ComputeServiceWS/types' packageName='computeservice.service'>
		<interface name='computeservice.service.ComputeServiceWSSEI' servantName='computeservice.service.ComputeServiceWSImpl'>
		</interface>
	</service>
</configuration>

Reply via email to